On Thursday, August 14, 2014 7:59:21 AM UTC-7, James Bardin wrote:
That limit is specifically for "Idle" connections. If MaxIdleConnsPerHost is 10, and you have 1000 active connections, and 10 are released, you should have exactly 10 idle and waiting and 990 active. No [keepalive] connection is immediately closed if there are no idle connections already. -
James, Thats what my expectation is and if it works that way, then thats great. But observation is different - during stress testing, till the total connections are below MaxIdleConnsPerHost, number of connections are constant, but as I increase the concurrency for stress testing, when the total connections from server to outside clients exceed MaxIdleConnsPerHost, the connections count explodes as most of them (above the limit) go in TIME_WAIT state and it does not become stable. Code -
http://play.golang.org/p/yK6Knh8RkE.
The backend services, are simple, accept the request, sleep for 80ms and send the response.
I am using wrk to do stress testing. After initial set of testing connections were constant and 10000 -
concurrency - a:
ESTABLISHED=> 10000
TIME_WAIT => 0
concurrency - 2a:(By starting another wrk client):
ESTABLISHED => 10000 -> 11000 (stable around here)
TIME_WAIT: Increasing -> 1939 - > 3714 -> 4156 -> ..->15066 -> ...42000 ->...
My understanding is after some time - most of the connections should be established, and TIME_WAIT should be very low, since connections are not idle, as the stress testing is on.
Please let me know if there is issue in the code, or this is expected the behavior.