实验说明 Golang HTTP 连接池参数
连接相对于其他对象,创建成本较高,资源也有限。如果没有连接池,在高并发场景下,连接关闭又新建,很快就会因为过多的TIME_WAIT(连接主动关闭方)导致无法创建更多连接了,程序被压死。
net/http 连接池参数
Go (测试版本 go 1.14)的net/http包是有连接池功能的,具体地,是 Transport 用于连接池化。
Transport is an implementation of RoundTripper that supports HTTP, HTTPS, and HTTP proxies (for either HTTP or HTTPS with CONNECT).
By default, Transport caches connections for future re-use.