空闲连接创建相关(related to idle connection creation) #2637
Replies: 4 comments 1 reply
-
Can idle connections be created gradually instead of all at once? Is it possible to add a strategy for this? If many clients start at the same time and create a large number of idle connections, Redis will be stuck for a long time(about 10 seconds). |
Beta Was this translation helpful? Give feedback.
-
Can you provide your connection pool parameters? |
Beta Was this translation helpful? Give feedback.
-
I think so . I encountered a Redis timeout issue. After a period of time, the interface becomes unresponsive if it is not accessed. After my analysis, I found out that a Redis query took about 15 minutes and 30 seconds, which is inexplicably long. However, when I refreshed it again in a short period of time, it returned to normal. But the first Redis query still had the same issue, taking 15 minutes and 30 seconds to respond. I now suspect that it may be related to the Redis connection pool, as the default minimum idle connections for Redis is 0. After a period of time, the connections may be lost, requiring the creation of a new connection pool. However, during this process of creating a new connection pool, the Redis query request took 15 minutes and 30 seconds to complete. 我遇到一个redis超时的问题。接口一段时间后没有访问,就会出现不响应。我分析后得知是redis查询花费了15分钟30秒左右,我不知道为啥这么离谱。但是在短时间内再次刷新又正常了。但是第一个redis连接得在15分钟30秒后才能响应。 我现在也怀疑可能与redis连接池有关系,因为默认redis的最小空闲连接为0.当一段时间后,连接没了,因此需要重新创建连接池,而我这个创建连接池的过程中,redis查询请求竟然要花费15分钟30秒。 |
Beta Was this translation helpful? Give feedback.
-
I think the problem maybe relate below article https://mp.weixin.qq.com/s/DuxEm_rOvr5bWdqC3MN5Jw so I try to add heartbeat in my code ticker := time.NewTicker(time.Duration(55) * time.Second)
//this is to send "ping" request each second for health-check
go func() {
for {
select {
case <-ticker.C:
//send heart-beat signal to check if everything is ok
if _, err := client.Ping(context.TODO()).Result(); err != nil {
log.Errorf("unable to ping redis, error: %+v", err)
} else {
log.Info("heartbeat ok!")
}
}
}
}() |
Beta Was this translation helpful? Give feedback.
-
空闲连接能不能别一次性就创建出来呢,能不能加个策略呢?如果大量客户端同时启动,一次性创建很多连接空闲连接,redis会卡很久
Beta Was this translation helpful? Give feedback.
All reactions