tags:

views:

235

answers:

2

What is the best practice around implementing WCF proxy pooling? What precautions should be taken in the design?

Any pointers in this direction is greatly appreciated.

+1  A: 

Why do you want to pool proxies?

Pools usually only exist when a resource (like a database connection) is scarce, expensive to build and possibly costly to maintain.

This should not be the case with WCF proxies, really - you create them as needed, and discard them when no longer needed.

I don't see any benefit or real use in trying to pool WCF proxies - what problem or issue are you trying to solve?

OK, thanks for your reply - I do understand what you're trying to accomplish - but I'm afraid, you're pretty much on your own, since I don't think there's any bits and pieces in the .NET framework and/or the WCF subsystem to would aid in creating proxy pools.

Marc

PS: as the article that Tuzo linked to shows, maybe you can get away with just caching the channelFactory objects. Creating those is indeed quite expensive, and if you can cache those for the lifetime of the app, maybe that'll be good enough for your needs. Check it out!

marc_s
Thanks for your reply...The website I am talking about makes heavy use of WCF. There is some performance overhead with wcf proxies as compared to the asmx proxies and that has to do with the way the proxy is instantiated.So, either I have the option of making the instances Singleton, so that the proxy instantiation is avoided or make it get an instance from a pool. I need to benchmark both the approach vis-a-vis the default behaviour.
rajesh pillai
Can't quite figure how you want to pool proxies across the ASP.NET page lifecycle just yet... not sure if "saving away" and grabbing the proxy again from e.g. cache or app session memory would be any faster in the end. I'd be interested in your benchmarks and findings, though!
marc_s
+3  A: 

If you want to go down that path, from Performance Improvement for WCF Client Proxy Creation in .NET 3.5 and Best Practices:

  • You need to implement the right synchronization logic for managing the proxies.

  • You need to make sure the proxies are used equally. Sometimes, you may want to implement a round-robin pattern for the proxies.

  • You need to handle exceptions and retries for the pool.

  • The pool size needs to be limited and configurable.

  • You may need to be able to create proxies even if when no proxy is available from the pool.

Tuzo
+1 excellent and very interesting article! Thanks for the link.
marc_s