B
Basel
Hi All!
I'm having a problem with a growing number of connections. my app
generates http requests and reads responses. the app creates large
number of threads (100 or more) that generates the requests, this is
the code:
ServicePointManager.DefaultConnectionLimit = 10;
ThreadFunction()
{
for(int i=0;i<1000000;i++)
{
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("http://localhost:8080/page.html");
request.KeepAlive = true;
System.IO.StreamReader reader = new
System.IO.StreamReader(request.GetResponse().GetResponseStream());
reader.ReadToEnd();
request.GetResponse().Close();
}
}
I'm using TCPView to monitor connections, after a couple of minutes
connections number starts to increase gradually , and some connections
closes.
decreasing ServicePointManager.MaxServicePointIdleTime will result in
creating more connection in less time
Is this problem is an issue of freeing resources? garbage collection?
My goal is to let each thread open one connection and stay active along
the way.
And what is the best way to achieve maximal throughput?
Basel
I'm having a problem with a growing number of connections. my app
generates http requests and reads responses. the app creates large
number of threads (100 or more) that generates the requests, this is
the code:
ServicePointManager.DefaultConnectionLimit = 10;
ThreadFunction()
{
for(int i=0;i<1000000;i++)
{
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("http://localhost:8080/page.html");
request.KeepAlive = true;
System.IO.StreamReader reader = new
System.IO.StreamReader(request.GetResponse().GetResponseStream());
reader.ReadToEnd();
request.GetResponse().Close();
}
}
I'm using TCPView to monitor connections, after a couple of minutes
connections number starts to increase gradually , and some connections
closes.
decreasing ServicePointManager.MaxServicePointIdleTime will result in
creating more connection in less time
Is this problem is an issue of freeing resources? garbage collection?
My goal is to let each thread open one connection and stay active along
the way.
And what is the best way to achieve maximal throughput?
Basel