gomemcache icon indicating copy to clipboard operation
gomemcache copied to clipboard

Questions about MaxIdleConns

Open time2k opened this issue 6 years ago • 1 comments

On the begining I set MaxIdleConns to 1 then did pressure test,I got "read: connection reset by peer" or "broken pipe" or "connect: can't assign requested address" panic

then I notice that MaxIdleConns with commend "Consider your expected traffic rates and latency carefully. This should be set to a number higher than your peak parallel requests."

so I set MaxIdleConns to 100+ and the light pressure test is ok I check the tcp connect with memcached server , exactly 100 ESTABLISHED connect but when pressure test over , the connects doesn't decrease

On my understanding, MaxIdleConns means to avoid low connect duration cost, make some basic connects to server the normal request. on busy time, it should increase the connect as much as the peak parallel requests, on idle time, it decrease to the MaxIdleConns setting number. It base on my experience on go-sql-driver/mysql and go-redis/redis, but when i turn MaxIdleConns lower than my parallel-pressture, it is show the panic above

Is my wrong understanding? is it exists a cycle timer to recycle the idle persistent connect? or some other recycle mechanism?

time2k avatar Nov 27 '18 16:11 time2k

After carefully read source code of this project, i know that the Client getConn() func provide connection primary from freeconn Client defined, if not, dial new connect. When job finish put into freeconn, if freeconn length more than MaxIdleConns close this connection. It design fine and should work fine.

time2k avatar Nov 28 '18 02:11 time2k