lily
lily

Reputation: 83

c3p0: what does `maxIdleTime` really mean?

in c3p0, maxIdleTime means:

maxIdleTime: (Default: 0) Seconds a Connection can remain pooled but unused before being discarded. Zero means idle connections never expire.

I don't get it. Let's say, if there are 10 awaiting connections in the connection pool, and after maxIdleTime has passed, there are still no new database requests, then all these connections should be discarded? then there will be 0 awaiting connections in the pool?

Upvotes: 2

Views: 11045

Answers (2)

zaarour
zaarour

Reputation: 105

If you have kept a large pool size (i.e. greater than what you anticipate as 99th percentile load), this will mean that you will have lots of idle connections lying around and it is better to clean them up periodically via maxIdleTime and idleConnectionTestPeriod parameter

May be, you will need to add too idleConnectionTestPeriod and preferredTestQuery be sure that connection are valid or not

Upvotes: 1

Steve Waldman
Steve Waldman

Reputation: 14083

If there are 10 Connections in the pool and no activity, then after maxIdleTime has passed, yes, they will all be expired.

But that does not mean there will be no Connections left in the pool. At the same time as the pool expires old Connections, it will acquire begin new Connections from the DBMS in order to uphold the minPoolSize configuration parameter.

Upvotes: 3

Related Questions