Hikari CP maxLifetime/idleTimeout [英] Hikari CP maxLifetime / idleTimeout

查看:1060
本文介绍了Hikari CP maxLifetime/idleTimeout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hikari CP版本:2.7.4

Hikari CP Version : 2.7.4

这实际上不是问题,但有一些疑问. a)maxLifetime:30分钟后退出连接.它会在终止连接时自动创建一个新的连接还是等待一个新的请求然后创建一个新的connectios?考虑到池中有多个minIdle.

This is actually not an issue but some doubts. a) maxLifetime : retires the connection after 30 mins. Will it also create a new connection automatically at the time of killing it or it waits for a new request and then creates a new connectios? considering pool has more than minIdle.

b)idleTimeout:闲置10分钟后会掉线吗?但是10分钟太高了.如果我将其标记为10s(从代码中看到10是min),可以吗,否则总会有比min-connections高的连接?

b) idleTimeout : it will drop after 10 mins of inactivity? but 10mins is too high. is it ok if i mark it as 10s(10 is min as seen from code) as otherwise there will always be connections higher than min-connections?

还有什么时候将连接标记为空闲?

ALso when does the connetion is mark as idle?

推荐答案

Hikari管家每30秒运行一次,这将关闭所有未使用且早于maxLifetime的连接.如果连接数超过minimumIdle,管家将关闭闲置时间长于idleTimeout的连接.

The Hikari housekeeper runs every 30s, which closes any connections that are not in use and are older than maxLifetime. If there are more than minimumIdle number of connections the housekeeper will close connections that have been idle for longer than idleTimeout.

如果您的应用程序正在运行时没有免费的连接,它将为您创建另一个连接,除非达到了maximumPoolSize位置,您需要在其中等待一个免费的连接.

If while your app is running there are no free connections it will create another connection for you unless its reached maximumPoolSize where you'll need to wait for one to be free.

创建新的连接会产生开销,通过池化连接,我们可以节省每次连接的时间,因此,将连接时间减少到10s,则与每10分钟相比会增加很多开销.

Creating a new connection has an overhead, by pooling the connections we save that connection time from happening everytime, so by reducing this down to 10s you'll be adding a lot more overhead in comparison to every 10min.

有关更多信息: https://github.com/brettwooldridge/HikariCP#configuration-把手宝贝

这篇关于Hikari CP maxLifetime/idleTimeout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆