HttpWebRequest efficient concurrency problem

The default number of requested connections is 2, and the default is 10 on the server operating system. If this concurrent connection limit is not modified, the number of http connections that the client can establish at the same time is only 2 or 10.

System.Net.ServicePointManager.DefaultConnectionLimit This can get the maximum number of connections currently set by default.

Adjust the value of System.Net.ServicePointManager.DefaultConnectionLimit to 500, and the speed will be improved several times. There are many other bloggers who have encountered similar problems and learn from their handling methods.

1. Code configuration

   System.Net.ServicePointManager.DefaultConnectionLimit = 512; // This value should not exceed 1024.

2.app.config   

<configuration>
<system.net> <connectionManagement>
<!--指定地址--> <add address = "http://www.baidu.com" maxconnection = "512" />

<!--任意地址-->
<add address = "*" maxconnection = "512" /> </connectionManagement> </system.net> </configuration>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325814856&siteId=291194637