pkg error redis: connection pool timeout pkg error redis: connection pool timeout pkg error redis: connection pool timeout pkg error redis: connection pool timeout pkg error redis: connection pool timeout pkg error redis: connection pool timeout pkg error redis: connection pool timeout pkg error redis: connection pool timeout pkg error redis: connection pool timeout pkg error redis: connection pool timeout pkg error redis: connection pool timeout pkg error redis: connection pool timeout pkg error redis: connection pool timeout
在将poolsize升至500后,有时会出现这样的错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
pkg error ERR max number of clients reached pkg error ERR max number of clients reached pkg error ERR max number of clients reached pkg error ERR max number of clients reached pkg error ERR max number of clients reached pkg error ERR max number of clients reached pkg error ERR max number of clients reached pkg error ERR max number of clients reached pkg error ERR max number of clients reached pkg error ERR max number of clients reached pkg error ERR max number of clients reached pkg error ERR max number of clients reached pkg error ERR max number of clients reached pkg error ERR max number of clients reached win id error ERR max number of clients reached response id error ERR max number of clients reached
出现这样的问题,可能是因为:
Redis is busy doing some expensive work (unlikely)
you use PubSub or Multi and don’t close it correctly (multi.Close() when multi is not needed any more) so connection is not returned to the pool
猜测的原因,是因为并发数太大,导致redis部分的pool connection没有及时释放。
注意到redis连接option中这样的一个参数:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
type Options struct { ...
// The maximum number of socket connections. // Default is 10 connections. PoolSize int // Specifies amount of time client waits for connection if all // connections are busy before returning an error. // Default is 1 seconds. PoolTimeout time.Duration // Specifies amount of time after which client closes idle // connections. Should be less than server's timeout. // Default is to not close idle connections. IdleTimeout time.Duration