在go-redis中,PoolTimeout、IdleTimeout和IdleCheckFrequency之间的关系是什么?

huangapple go评论106阅读模式
英文:

Relation between PoolTimeout, IdleTimeout & IdleCheckFrequency in go-redis

问题

有人可以告诉我在go-redis中的PoolTimeoutIdleTimeoutIdleCheckFrequency之间的关系吗?

疑问:

  1. 如果我指定了PoolTimeout为20毫秒,IdleTimeout为20毫秒,PoolSize为100,IdleCheckFrequency为1分钟。假设连接池中的所有连接都被使用,并且一个连接完成其操作。那么在1分钟的间隔内,请求一个新的连接会等待IdleCheck运行吗?
  2. 如果我指定了PoolSize为100,即使没有正在执行的Redis操作,客户端是否会保持100个与Redis的连接打开?

环境:

  1. Go - 1.7.4
  2. Redis - 3.2.6
  3. Go-Redis - v5.2
英文:

Can someone let me know the relation between PoolTimeout, IdleTimeout & IdleCheckFrequency in go-redis?

Doubts:-

  1. If I specify PoolTimeout 20ms, IdleTimeout 20ms, PoolSize 100 & IdleCheckFrequency 1 min. Let's say all the connection in the pool are used and a connection finishes its operation. Then will the request for a new connection wait till the IdleCheck is run in 1 min interval?
  2. If I specify PoolSize 100 will the client keep open 100 connections to redis even if there is no active client operation being performed to Redis?

Environment:-

  1. Go - 1.7.4
  2. Redis - 3.2.6
  3. Go-Redis - v5.2

答案1

得分: 4

这个问题在GitHub上已经有答案了,在这里。我将以下相关部分贴在下面:

> PoolSize 限制了最大的打开连接数。如果应用程序处于空闲状态,go-redis 就不会打开任何连接。
>
> 当有命令需要处理且连接池中没有空闲连接时,会打开一个新的连接。空闲连接在空闲时间超过 IdleTimeout 后会被关闭。
>
> IdleCheckFrequency 指定了我们检查连接是否过期的频率。这在应用程序处于空闲状态且没有活动时是必需的。通常,当 go-redis 请求连接池提供一个(健康的)连接时,空闲连接会被关闭。

英文:

This has been answered in github here. Just posting the relevant parts below:-

> PoolSize limits max number of open connections. If app is idle then
> go-redis does not open any connections.
>
> New connection is opened when there is a command to process and there
> are no idle connections in the pool. Idle connections are closed after
> they are idle for IdleTimeout.
>
> IdleCheckFrequency specifies how often we check if connection is
> expired. This is needed in case app is idle and there is no activity.
> Normally idle connections are closed when go-redis asks pool for a
> (healthy) connection.

huangapple
  • 本文由 发表于 2016年12月11日 00:53:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/41077942.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定