Tuesday, August 14, 2007

Implementing a WCF Service with High Performance

Hi Folks,

WCF gives the developer the tools to provide high performance for your WCF Service,once of the key features to provide high performance WCF Service caled "Service Throttling";this concept simply provide you the values you want to set to manage the following:

1) Maximum Concurrent sessions.
2) Maximum Concurrent Calls.
3) Maximum Concurrent Instances.

These values should be set on the host app of the service,and the admin has to monitor the server which host WCF Services to monitor the perfomance of the running WCF services.

To Implement Service throttling on your service,you have to write this code before open the serviceHost Object :

// Required for the ServiceThrottlingBehavior class
using System.ServiceModel.Description;

ServiceHost host = new ServiceHost(…);
ServiceThrottlingBehavior throttleBehavior = new ServiceThrottlingBehavior();
throttleBehavior.MaxConcurrentCalls = 40;
throttleBehavior.MaxConcurrentInstances = 20;
throttleBehavior.MaxConcurrentSessions = 20;
host.Description.Behaviors.Add(throttleBehavior);
host.Open();


Note : that we set these values before open the servicehost object.

Take care of the following Tips :
1) Default Concurrent Instances is Int32.Max = 21474836467
2) Default Concurrent Calls is 16
3) Default Concurrent Calls is 10


Hope this helps for WCF developers :)




Regards,
Moustafa arafa

2 comments:

Anonymous said...

salam,
i just want to thank you for this article and i have a question..
i have a company with 3000 employee and lets say that all of them r accessing the database.. will a wcf service be able to handle 3000 concurrent calls?
what r the settings to throttle behavior i need to change?

Anonymous said...

Good dispatch and this enter helped me alot in my college assignement. Thank you seeking your information.