13

When checking the System.Net.ServicePointManager.DefaultConnectionLimit in .Net 4 in my debugger, I see really high numbers. I see 24 on one machine and see 48 on another machine.

This is even the case for a newly created ASP.NET MVC 3 project without any configuration changes done to it. Is this a bug? The documentation clearly states that the default is 2:

The maximum number of concurrent connections allowed by a ServicePoint object. The default value is 2.

From http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit(v=VS.100).aspx

The DefaultNonPersistentConnectionLimit and DefaultPersistentConnectionLimit fields are more realistic 4 and 2, respectively, but the DefaultConnectionLimit number seems out of range.

JOG
  • 5,590
  • 7
  • 34
  • 54
Johnny Oshika
  • 54,741
  • 40
  • 181
  • 275

1 Answers1

16

It's not a bug. It's propably 12 per CPU.

The value comes from <connectionManagement> in your Web.config or Machine.config. If neither of files contains element it's probably configured by autoConfig=True setting at <processModel> element.

Jakub Šturc
  • 35,201
  • 25
  • 90
  • 110
  • 8
    If you were to decompile the v4.0 System.Web and look at the 'SetAutoConfigLimits' method, you'll see this set to 2 * # of CPUs. In .NET 4.5 this appears to have been changed and the value is now set to Int32.MaxValue (0x7fffffff). – Kevin Pullin Mar 18 '13 at 22:54
  • 1
    That should've been 12 * # of CPUs. – Kevin Pullin Mar 18 '13 at 23:10
  • 3
    Kevin is totally right, with framework 4.5 it is indeed Int32.MaxValue. It' in the System.Web.HttpRuntime class. – Benjamin Baumann Jan 22 '14 at 15:28
  • 6
    For web projects it's set to Int32.MaxValue. But in an Azure WorkerRole(and I haven't checked, but I suspect a console or desktop app too) it's set to 2 by default. Probably because the HttpRuntime isn't being invoked. – Steve Sheldon Dec 05 '14 at 15:22