Is there ever a reason to set maxIdle > maxActive for connection pools?

巧了我就是萌 提交于 2019-12-11 01:58:29

问题


I'm just learning about connection pools, and I was wondering if there's ever any reason to set maxIdle > maxActive.

This is my understanding:

Idle connections are connections that have been created and are waiting to be used. It becomes an active connection once a client borrows it.

minIdle determines the number of initial connections to create in a pool.

When a client tries to use the pool, an idle connection is given. If there are no available idle connections, the pool will create one. When an idle connection becomes an active connection, if the number of idle connections fall below minIdle, the pool will create connections until there are at least minIdle idle connections. When a client is finished with an active connection, the connection becomes an idle connection again.

This means the number of idle connections can grow, so maxIdle prevents the connection pool from having too many idle connections. Since maxActive caps the number of connections that can be borrowed, there is no need to have a maxIdle > maxActive.

来源:https://stackoverflow.com/questions/22262892/is-there-ever-a-reason-to-set-maxidle-maxactive-for-connection-pools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!