Friday, April 15, 2011

Why does WCF limit concurrent connections to 5?

I have a WCF service (basicHttpBinding) hosted in II7 on Vista that I expect to handle many requests concurrently. I'm attempting to load test the service by spawing 200 threads in a test app and calling the WCF service. I've run this test app on the same machine as the server as well as multiple other computers and I always get the same result - no more than 5 workers are used. Is this a WCF, HTTP or IIS bottleneck?

From stackoverflow
  • This is a feature to prevent denial of service attack. Out of the box, WCF is designed to be secure. Check the service behavior, look in msdn for maxConcurrentCalls and maxConcurrentSessions configuration. I think the limit is 10, but I could be wrong.

    James Cadd : This is the closest answer - if I changed maxConcurrentCalls the number of WCF workers actively reflects that value, to a point. Anything over 10 doesn't actually run more of my workers. Strangely, the default is 16 but I can't get 16 calls to be active at the same time.
    Vadmyst : The default limit is 16 not 10. Btw 0x10 is 16 :)
  • WCF is secure by default. This means that the default settings limit what you can do with your WCF service to avoid things like denial of service attacks. This is great for internet facing web services, but it can sometimes bite you. Depending on what bindings and behaviors you use, it could be a setting in any of those.

    Here is an overview of these settings - it'll require some experimentation on your part to determine what exactly is biting you.

  • No, it's just the default throttling settings in WCF. It's configured in the serviceThrottling element of a behaviour in the service config file, which has a maxConcurrentSessions attribute. Default 5, but you can set it to whatever you want.

  • Here's a nice article on WCF Instance Management from MSDN magazine by Juval Lowy: http://msdn.microsoft.com/en-us/magazine/cc163590.aspx Issue from June 2006 (in case if MSDN will butcher their links again).

    It explains techniques and settings for managing service lifecycle (throttling is one of them) and shows what settings to apply to increase number of concurrent connection.

0 comments:

Post a Comment