标签:mtu cifs BMI 使用 timeout you kvo default hsi
// NewOption by self specified timeouts // default auto load conf unless you disable it by DisableAutoLoadConf() func NewOptionWithTimeout( dialTimeout, // Dial timeout for establishing new connections. readTimeout, // Timeout for socket reads. If reached, commands will fail writeTimeout,// Timeout for socket writes. If reached, commands will fail poolTimeout,// Amount of time client waits for connection if all connections are busy before returning an error idleTimeout,// Amount of time after which client closes idle connections. liveTimeout time.Duration, // Amount of time after which client closes exist connections. poolSize int) *Option { // Maximum number of socket connections. if dialTimeout == 0 { dialTimeout = REDIS_DIAL_TIMEOUT } if readTimeout == 0 { readTimeout = REDIS_READ_TIMEOUT } if writeTimeout == 0 { writeTimeout = REDIS_WRITE_TIMEOUT } if poolTimeout == 0 { poolTimeout = REDIS_POOL_TIMEOUT } if idleTimeout == 0 { idleTimeout = REDIS_IDLE_TIMEOUT } if poolSize <= 0 { poolSize = REDIS_POOL_SIZE } opts := &redis.Options{ DialTimeout: dialTimeout, ReadTimeout: readTimeout, WriteTimeout: writeTimeout, PoolSize: poolSize, PoolTimeout: poolTimeout, IdleTimeout: idleTimeout, LiveTimeout: liveTimeout, IdleCheckFrequency: REDIS_IDLE_CHECK_FREQUENCY, } opt := &Option{ Options: opts, PoolInitSize: REDIS_POOL_INIT_SIZE, autoLoadConf: REDIS_AUTO_LOAD_CONF, autoLoadInterval: REDIS_AUTO_LOAD_INTERVAL, maxFailureRate: MAX_FAILURE_RATE, minSample: MIN_SAMPLE, windowTime: WINDOW_TIME, configFilePath: "", useConsul: true, } return opt }
查看源码之后,PoolTimeout会影响客户端的错误率,但是不会影响连接的生存时间。liveTimeout和IdleTimeout会影响连接池中一条链接的的生存时间。再看两个参数值,发现liveTimeout使用的是默认值5min,而IdleTimeout使用的居然是和ReadTimeout相同的200ms,也就是说,一条链接如果空闲超过200ms,则会被关闭。所以综合分析来看,可能是两点原因导致了这种情况:
将IdleTimeout 配置参数从200ms改到2h之后,测试后发现明显可以降低客户端连接关闭的QPS。 然后进行上线
1. 客户端连接关闭QPS明显降低
2. redis proxy CPU 使用率下降了一倍以上
以上仅个人观点,欢迎批评指正
记一次redis client配置使用不当造成Proxy CPU负载过高
标签:mtu cifs BMI 使用 timeout you kvo default hsi
原文地址:https://www.cnblogs.com/cicada23/p/12779346.html