MaxIdleConnsPerHost int
但是我没有看到整个 http 客户端的任何 MaxConns,为什么?
从文档:
// MaxIdleConnsPerHost, if non-zero, controls the maximum idle
// (keep-alive) connections to keep per-host. If zero,
// DefaultMaxIdleConnsPerHost is used.
MaxIdleConnsPerHost int
// MaxConnsPerHost optionally limits the total number of
// connections per host, including connections in the dialing,
// active, and idle states. On limit violation, dials will block.
//
// Zero means no limit.
MaxConnsPerHost int
最佳答案
I do not see any MaxConns for the whole http client, why?
因为没有。如果您不想与该客户端发出超过 n 个并发请求,请不要这样做(如果客户端会限制,这将是一个主要的使用方法)。
If I only limit MaxIdleConns (per the whole client) is it possible to have more than this limit of active connections?
是的。
MaxIdlConns
限制空闲连接而不是非空闲连接。
关于http - Golang http客户端为什么有MaxConnsPerHost没有MaxConns,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61428428/