Monday, November 3, 2008

WCF Performance: Don't take it for granted

Conclusion first,

Our Challenge: 300 user base, when users execute complex search queries that will go through wcf services and for that our db would take more time than usual in executing the searches then other users will experience significant delays while interacting with the system. They will get web service calls timing out but you find CPU, RAM and other hardware resources were underutilized on IIS and DB box.


  • By default WCF can't serve more than a limited number of concurrent users or requests. OUT of box WCF comes with conservative performance settings and in most of the cases you will have to tune WCF services yourself.

the key parameters that are to be set in services config file

<serviceThrottling maxConcurrentCalls="Integer"
maxConcurrentSessions="Integer" />

Following values should give you a good performance boost, you can even go beyond 10000 but you sould perform som load testing to see if you have got enough CPU and RAM to support.

<serviceThrottling maxConcurrentCalls="3000"
maxConcurrentSessions="3000" />

  • basic http bindings for WCF web services provide almost double the performance as compared to secure http bindings

MS products, ready to use:

We developed the application based on WCF web services but didn't realize that we should be thinking of tuning WCF before going into production, we took it for granted that things would go normal as they used to do with other ms products (like .net runtimes, IIS etc) simply because we did not have a very large user base but what we did not know was that WCF came out of box tuned for a very limited set of users.

the key config parameters ,

if your application is running in an environment where WCF services perform some blocking operation (because of some dependency on external processes like db or file read/write operations ) then you should consider setting the following parameters appropriately in the services config file.

<serviceThrottling maxConcurrentCalls="Integer" maxConcurrentInstances="Integer" maxConcurrentSessions="Integer" />

Me and my mate Merill worked together on this task and he was the first who detailed what we did in his blog, so instead of duplicating I refer to his post, check this nice article

Stay tuned,

However beside tuning WCF, I have learned another lesson. The degrade in performance might not due to a single factor but may be a combination of factors when combined give rise to the problem. Trying fixes one by one might not give you a success, leaving you scratching your head. My next blog will on how to attack a slow performing application and what to look for & where, so stay tuned.