Simple steps to scale up WCF srevices drastically

Every .NET developer must have written/used WCF services  many times in different projects. But as long as the usage of the service are limited, it works smoothly. But as the number of requests increases rapidly, things starts become ugly. If the number of requests goes beyond a limit at certain time interval, you may start seeing critical issues like service may stop taking new request. As you will read this post, you will come to know the huge potential of your services and unseen ceiling applied by default configuration

In this post, I will be discussing two major items that can tremendously boost the performance of your services
1- WCF throttling
2- System.NET changes

WCF Throttling

Before moving ahead, the basic question arises that  What is throttling?

In simple words, Throttling is a way to control or limit the number input(request) in a certain interval so that the resources at server stay at healthy state.

WCF throttling by default provides some throttling values set and allows us to configure that.

There are three main properties properties provided by default WCF throttling.

1- maxConcurrentCalls – How many number of request can be accepted by a service in a second.

2- maxConcurrentSessions – How many number of request can be processed by a service in a second.

3- maxConcurrentInstances – How many number of instances of service can be created by a service in a second.

Now let’s discuss one by one.

maxConcurrentCalls – denotes number of request can be accepted by service in a second. If the number of requests exceeds the set value, the request starting queuing up and if this goes on, the queue gets full and then further request start getting denied.

maxConcurrentSession – denotes the number of concurrent sessions in a second of a ServiceHost. If I elaborate it a bit, then in a sec, this number of requests can be in processing state.

maxConcurrentInstances – In a normal scenario (default case where we did not use any instance management) this number of instances can be created in a sec. So when a request comes to the service, a new instance is created to serve that request. Again if the number of instance throttle reached, no more instances would be created.

So before discussing further, can you think of any formula in these three?

So before wasting anymore time, let me reveal thatsum1.It means, say if we allow maxConcurrentcalls as X it means X instances would be made to handle at a specific point and maxConcurrentSessions as Y number of request that is getting processed which Y number of service instances. So  maxConcurrentInstances should be set as X+Y..

I hope you all got the ideas about these settings. Now You will be amazed to see the default value of these setting. These are

maxConcurrentCalls – 16
maxConcurrentInstances – 26
maxConcurrentSessions -10

So it means your service can take at max 16 calls and can have max 10 concurrent instances per sec. Don’t you thinnk that it is very less. In normal scenario if the service is consumed by a single client and number of calls per second is not much then you may not realize it.But if your service is consumed by 10 to 100s or more clients then some of the client start getting timeout or no response error from service.

Even I was working on a application which has WCF service, and it was getting more that 100 calls in a sec and WCF was silently started denying the request. After a lot of investigation I reached to the actual cause.

So now the bigger question – What should be the optimum value?

Now before moving further, the above values are default values if one is using .NET 4.0 or less. But if you are using the .NET 4.5, Microsoft made it dynamic and changed it significantly and as

maxConcurrentCalls – 16 times of number of processors
maxConcurrentSessions – 100 times of number of processors
maxConcurrentInstances –  Sum of maxConcurrentCalls and maxConcurrentSession.

Normally at our production servers, we used 8 or 16 or more processors. Correct. let’s see the value in case of 8 cores

maxConcurrentCalls – 144
maxConcurrentSessions – 800
maxConcurrentInstances –  944

Earlier which was used to in 10s per sec, which is now in 100s. Awesome!!

So if we are using the default values then we are just victim of a default ceiling and can set it in config file as

  <behavior name="myServiceBehavior">
     <serviceThrottling maxConcurrentCalls="144"
	maxConcurrentInstances="944" maxConcurrentSessions="800" />

if using earlier version of .NET framework 4.5 so we should modify it accordingly. If you are using .NET 4.5+ then you are lucky and can safely ignore it.


If your application server and WCF service is hosted on different servers then it may be again major bottleneck. This contains the settings that says how many outbound request can be made at a time to another server. And the default value is 2 per IP. It can be pictorially shown as

system.netThis can be reset at machine level by changing machine.config or web.config/app.config for web application and windows based client respectively.

So what should be the optimum value. We can put it as per requirement say 100. But we should not put it to too high because if accidentally it started making calls to the service then it may be disastrous for our service. So make it reasonable and based on the requirement. It can be set as

    <add address="*" maxconnection="100" />

So I hope you enjoyed this post. Please feel free to share you precious comments.


Learning {{AngularJS}} with ASP.NET MVC – Part 6

It’s been around a month since I wrote the fifth part of the series on AngularJS. We have covered a bunch of concepts in our last five posts. I will advise to go first the earlier posts then continue reading it. Links of my earlier posts on this series are.

Learning {{AngularJS}} with Examples–Part 1

Learning {{AngularJS}} with Examples–Part 2

Learning {{AngularJS}} with ASP.NET MVC – Part 3

Learning {{AngularJS}} with ASP.NET MVC – Part 4

Learning {{AngularJS}} with ASP.NET MVC – Part 5

In our last post, we created a sample where we had a page that comprised two views : Talk details and Speaker Details. We fetched two sets of data (Talks and Speakers) from server via  AJAX call and rendered on the page using templates with the help of Angular rendering engine. In this application, we are going to use again the same application and add some more features which are relevant in our day to day coding.

In today’s post, we will use almost the same concepts that we discussed in our last post but use it for different scenario. Let’s put our picture tracker.

trackerHere I highlighted four components and we had already used it one or other ways in earlier posts. But we’ll discuss the new highlighted components briefly here as well.

Continue reading

Presented on AngularJS at C# Corner Delhi chapter event – 28th June

Hello All,

C# Corner again organized a fantastic full day event on 28th June where attendees got a chance to learn hot technologies and chance to hear big names like like Mr Mahesh Chand and Mr Pinal Dave. In this full day event, I presented one of the most discussed technologies, AngularJS. It was an awesome session which was full of knowledge, demos and humor. I covered the following points

  • Intro to AngularJS
  • First Angular Application
    • Controller
    • $scope
    • Expression
  • Flow of an Angular App
  • Another Demo
    • DataBinding
    • ng-repeat
    • Filter
    • Modules, Views and Controllers (All in one)

Continue reading

Learning {{AngularJS}} with ASP.NET MVC – Part 5

This is the fifth part in the series of AngularJS. We have discussed the basic components of AngularJS in our earlier posts. Please find the links of my earlier post on this series as

 Learning {{AngularJS}} with Examples–Part 1

Learning {{AngularJS}} with Examples–Part 2

Learning {{AngularJS}} with ASP.NET MVC – Part 3

Learning {{AngularJS}} with ASP.NET MVC – Part 4

So let’s move to series tracker and see what are we going to learn today.

structuctureSo far, we have discussed five main components. Today we will be discussing Views and Routing.

Continue reading

Got awarded Microsoft MVP fourth time in a row

Hello All,

imagesI am very happy to inform you all that I have been awarded Microsoft Most Valuable Award fourth times in a row. First time, I got this award on 1st July 2011 and getting it consecutively since then. It is really a great honor and matter of pride to me. I received this award ASP.NET/IIS category since beginning.

This award is never been possible without all of you. I would like to thank each one of you for your support and feedback. I will try to spend more time in community and sharing knowledge on various technologies.

Continue reading

Leverage output caching with IIS7.X and IIS8.X

Caching is one of key items that is being discussed whenever we talk about the performance of a web application. We always to use caching as a primary tool while designing and development of a web application. ASP.NET itself supports different kind of caching for handling various scenarios. Although we talk about it a lot, but I have seen that it is not implemented properly at most of the applications

I’ll not talk about it in detail about Caching in this post. Although I wrote an article on this topic in detail on long back, you can refer it for getting more information

State management and ways to handle Cache in a Web Farm/Web Garden scenario

Note : As this post was written long back (Apr 2011) some of part of could be old and may not be relevant in the current scenarios.

Let’s comeback to the topic. There are different ways to implement caching and one of the caching technique is called Output caching. But let’s understand that what is output caching?

Continue reading

Learn AngularJs with me at C# Corner Delhi Developer’s Day on 28th June

Hello All,

C# Corner brings another full day event at its Noida office on 28th June. I’ll be discussing on one of the Hot technologies AngularJS and it will be fully interactive session with lots of demos. The event details are

Event Name – C# Corner Delhi Developer’s Day

Date – 28th June 2014

Time – 9:30 to 5:30 PM

Venue –  MCN Solutions Pvt. Ltd.
H-217, First Floor, Sector-63
Noida, Uttar Pradesh, INDIA

Continue reading