B.Sc. of Computer Science from faculty of computer and information sciences -Ain Shams Univ,Cairo,Egypt. I have MCAD.NET,MCSD.NET,MCTS (SQL 2005) Early Achiever ,MCT & C# MVP. I'm INETA User group lead & DotNet Boom supportive development manager for www.dotnetboom.net community as well. I'm working as Consultant as well as Technical Lead. I like to learn more and more about new technologies.I like also to help & share information with others,Keep your eye on my blog.

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

1 comments:

Ahmed Yahya saeed (aswani2002@gmail.com) 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?