What are the Pitfalls of using a shared static WCF

2020-07-23 05:22发布

问题:

I am considering using a Shared (read static) WCF proxy client for a high throughput application. I believe there is a performance gain in doing this, but I have not benchmarked this as yet.

Are there some serious pitfalls to this idea?

From my research I can see that there is the issue of handling the fault state, it is not clear what the flow on affect of this state would be to other pending requests.

Does anyone have any experience recovering a WCF proxy from it's faulted state?

thanks in advance!

回答1:

Once the channel is in a faulted state it will stay that way. So yes, I think a static client would be problematic. I started off that way as well but ended up creating and opening a new channel for each call instead. There doesn't seem to be much of a performance trade-off.

For reference I'm doing about 30-60 requests of about 5K-30K per request per second on a quad core machine from another quad core machine. WCF has been holding up quite well so far.



回答2:

I just discovered that calling Close() on the proxy will block when calls that are One Way operations executing [OperationContract(IsOneWay = true)]. This would change the flow as well.