ServicePointManager.DefaultConnectionLimit == 2? The Depends continues…
A few days ago I posted about the missing documentation about ServicePointManager.DefaultConnectLimit and that its default value is not always 2 (the value actually depends on the target server, if it’s a remote server or your localhost).
Yesterday, after my advanced WCF course, I got an email from one of the attendees that pointed out that indeed the default value is 2 for remote servers, but only in desktop applications (console, win forms…). In WCF services that are hosted in a web application, the default value for outgoing connections is actually 12 times the number of cores.
First of all, thanks Miron for noticing this behavior of web applications, and I’ll just want to add some more information about this setting in web environemnts:
- The change in the default value comes from System.Web.HttpRuntime, meaning it will be for any web hosted application, such as ASP.NET, WCF, and ASMX Web Services.
- The documentation in MSDN indeed mentions a changed setting with ASP.NET: “When used in the server environment (ASP.NET) DefaultConnectionLimit defaults to higher number of connections, which is 10”.
As you can see, this documentation is also outdated…
Hope you can use this information for better configuring your desktop clients, web applications, and services (self-hosted, or IIS hosted).