Here is the very simple scenario I would like to show:
internal class Program
{
private static void Main(string[] args)
{
var uri = new Uri("http://myserver.com");
ServicePointManager.FindServicePoint(uri).ConnectionLimit = 1000;
for (int i = 0; i < 1000; i++)
{
WebRequest.Create(uri).BeginGetResponse(a => { }, null);
}
Console.WriteLine("done");
Console.ReadLine();
}
}
And corresponding App.config:
<system.net>
<connectionManagement>
<clear/>
<add address="*" maxconnection="1000" />
</connectionManagement>
<defaultProxy>
<proxy proxyaddress="http://127.0.0.1:8888" />
</defaultProxy>
</system.net>
Let say myserver.com responds 10 seconds (I emulated this in Fiddler via AutoResponder).
In the proxy server (Fiddler) I see that only 14 http requests are sent at application start. Then number of active connections is growing but very slow, about +1 request in 1-2 sec. So after 1 minute of work the number of active http requests is about 50, but not 1000.
Is there any configuration that I can change to force .NET to open if not 1000 real http request but at least 200-300?