You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Sarath Ambadas <sa...@gmail.com> on 2011/08/05 07:50:16 UTC

[pool] connections getting destroyed immediately if more than Max Idle

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.

Thanks much
Sarath

Re: [pool] connections getting destroyed immediately if more than Max Idle

Posted by Phil Steitz <ph...@gmail.com>.
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
changed):

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.

Phil
>
> Thanks much
> Sarath
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org