commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <>
Subject Re: [pool] connections getting destroyed immediately if more than Max Idle
Date Fri, 05 Aug 2011 15:57:48 GMT
On 8/4/11 10:50 PM, Sarath Ambadas wrote:
> Hi
> I am using commons pool for pooling my connections in my application.
> I set the pool config properties as given below
> Max Active = 25
> Max Idle = 1
> MinEvictableIdleTimeMillis = 1 hours
> TimeBetweenEvictionRunsMillis = 10 min
> MaxWait = 5 min
> When I do some load testing, more connections get created, but all the
> connections get destroyed(as soon as returned to the pool) immediately
> except 1 (Max Idle what ever value it has). I was thinking even if there are
> more connections than MaxIdle (but less than Max Active), the connections
> will be present in the pool and they will be destroyed only when
> MinEvictableIdleTimeMillis is reached.
> Could anyone please clarify this. Can I achieve this functionality where
> connections wont get destroyed immediately if there are more than MaxIdle
> but will stay in pool till timeout.
This comment applies to pool 1.x (pool 2.0 property names are being

maxIdle puts a limit on the number of instances that can be idle in
the pool at any given time.  If I understand correctly what you are
trying to do, you should set maxIdle = maxActive and if you want to
evict instances idle too long, keep the eviction timer settings
above.   The maxActive setting actually limits the total number of
instances under management by the pool - idle in the pool waiting to
be checked out + checked out to clients.  So if you set maxIdle =
maxActive, the pool will never have more than maxActive instances
under management, but if demand does drive it to grow to creating
and lending out maxActive concurrently at some point, all maxActive
instances can return and sit idle in the pool together without any
being destroyed.  If you make maxIdle < maxActive and you hit a
demand spike that causes maxActive to be created and checked out,
only maxIdle of them will be allowed to sit idle in the pool
together at a any given time.

> Thanks much
> Sarath

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message