Search This Blog

Tuesday, January 7, 2014

Increase performance of wcf service

How to increase the performance of the WCF Service, simply change the service behavior to optimize the performance of the application.
here is the snippet
[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession,
ConcurrencyMode=ConcurrencyMode.Multiple)] 

update your service behavior with above snippet,
Explanation:- here we are adding InstanceContextMode=InstanceContextMode.PerSession it mean that it will create object of service per session or in other words one object for each session, and second one we added ConcurrencyMode=ConcurrencyMode.Multiple ConcurrencyMode mean how many request we can process at once change it to multiple mean we can process multiple request at a time.

How to test RESTFul WCF Services?

When we are creating RESTFul WCF services, the first question arise how to test our WCF service is working properly or not.
For testing WCF Service mostly we are using one tool i.e. Fiddler with the help of this tool we can test our WCF service.
i have a very easy why to test the WCF service. First of all enable help in your WCF Service if you don't know please refer my old post to enable help in WCF service, after enabling  help run your WCF service on browser at the end of service address put "/help" (remove "") then press enter.
it will display all the method like below screen.
Click on Method which you want to test it will display the description of all the method what will be the url pattern, what is the request/response format  and body of the method.


Then open fiddler click on composer tab





 Select the method type GET, POST etc according to your method.
copy and paste url of the method from help page.
and in request body copy and paste request body from help page and change the data if you want.
in request header define the Content-Type then click on execute. It will Call your WCF service, you can run WCF Service and put break point to debug the application.

may be this will help you.