Golang http.DefaultClient 连接服务端压测时出现大量TIME_WAIT异常
2017-09-15 20:27
686 查看
今天在做一个压测场景时,通过golang作为client去连接服务,在client的服务器上出现大量的TIME_WAIT连接。经过查找资料,得到解决,参考如下:
The default http.Transport is opening and closing connections too quickly. Since all connections are to the same host:port combination, you need to increase
You can set this globally on the default transport:
Or when creating your own transport
The default http.Transport is opening and closing connections too quickly. Since all connections are to the same host:port combination, you need to increase
MaxIdleConnsPerHostto match your value for
num_coroutines. Otherwise, the transport will frequently close the extra connections, only to have them reopened immediately.
You can set this globally on the default transport:
http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = numCoroutines
Or when creating your own transport
t := &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, }).DialContext, MaxIdleConnsPerHost: numCoroutines, MaxIdleConns: 100, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, }
相关文章推荐
- Linux网络tcp连接大量CLOSE_WAIT和TIME_WAIT状态的出现和解决方法
- HttpClient 大量连接等待异常的处理
- [总结]数据库连接池设置不当导致大量的本地连接出现time_wait状态。
- HttpClient当HTTP连接的时候出现大量CLOSE_WAIT连接
- 服务器出现大量的数据库连接WAIT_TIME
- http短连接大量time wait解决方案
- 系统出现大量TIME_WAIT状态的连接的解决办法
- zabbix proxy 服务器 netstat 出现大量Time_Wait连接问题
- 针对http当出现大量time-wait出现程序反应慢问题
- HttpClient4 客户端出现TIME_WAIT
- Android Studio 进行网络连接时,出现 HttpResponse reponse =new DefaultHttpClient().execute(request)处有错误
- linux服务器出现大量的TIME_WAIT状态的TCP连接的处理办法
- Android studio 进行网络连接时,出现 HttpResponse reponse =new DefaultHttpClient().execute(request)处有错误
- 服务器端主动关闭连接, 产生的TIME_WAIT状态为什么会占用服务端大量端口?
- TCP连接出现大量TIME_WAIT的解决办法
- 服务器出现大量的127.0.0.1:3306 TIME_WAIT连接 解决方法 [转载]
- TCP连接出现大量TIME_WAIT的解决办法
- linux 连接oracle出现大量TIME_WAIT
- HttpClient出现TCP连接异常关闭发送RST包
- 解决服务器出现大量CLOSE_WAIT和TIME_WAIT连接的方法