gomemcache
gomemcache copied to clipboard
Questions about MaxIdleConns
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?
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.