ServicePointManager.DefaultConnectionLimit sets the maximum number of concurrent sessions for a Worker Role, but how can I find the best value here?
Asked
Active
Viewed 1.6k times
2 Answers
11
According to Microsoft Support, 12 * [Number of logical CPUs] is a good value.
If you're using .Net 4.5, the defaults are already set to more sensible values.

Community
- 1
- 1

Samuel Jack
- 32,712
- 16
- 118
- 155
-
I'm not sure if that last line is correct - I checked the default in my application, which is built specifically using .Net 4.5, and it still defaults to 2. Someone else might want to verify and alter the answer (if they find the same case, or make the comment more specific as it might be more than simply .Net 4.5 - MSDN does state: "When used in the server environment (ASP.NET) DefaultConnectionLimit defaults to higher number of connections, which is 10.", at http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit(v=vs.110).aspx). – Kit10 Aug 14 '14 at 17:03
-
1I can confirm that on my Web API Azure website (.NET 4.5) `DefaultConnectionLimit` is set to 2. The linked answer suggests that the "sensible defaults" are set by "classic" ASP.NET (System.Web) whereas in other hosting environments, for example Web API in my case, thing may be different. – Ohad Schneider Sep 17 '14 at 15:00
-
3Note that in ASP.NET 4.5 it is now `int.MaxValue` – Ohad Schneider Oct 04 '14 at 13:34
-
@OhadSchneider, any msdn links for this? – Aug 31 '16 at 04:17
-
@MahdiK. I think I just looked at it in ILSpy – Ohad Schneider Aug 31 '16 at 09:17
-
1@OhadSchneider: I guess the value is still 2, and this happens when you self host the app. However hosting on a web server, you read the value from machine-level configs which makes it 12 connection per logical CPUs. Reference: for asp.net apps the default connection limit is managed at machine level configs in processModel/autoConfig: https://msdn.microsoft.com/en-us/subscriptions/administration/7w2sway1(v=vs.85). Please note that at the below link the value seems to be 2 which is not the current default value which is 12. https://support.microsoft.com/en-au/kb/821268 – Sep 12 '16 at 02:25
6
This is the best advise on getting the value is here on forums. Also read the knowledge base article listed.
The point is that the default of 2 will get you into trouble with connection drops.

Scott Densmore
- 1,459
- 10
- 10