You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Sandy McArthur <sa...@apache.org> on 2006/11/01 02:14:43 UTC
[pool][dbcp] trimming the pool size after load spikes
Phil and others interested in Pool and DBCP,
While working on resolving POOL-86 which is about finding a way to
trim the pool size down after a load spike to try to minimize used
resources during off peak load levels.
I've suggested a decorator that wraps a pool and monitors it's usage
and intercepts calls to returnObject and directs them to
invalidateObject occasionally in order to shrink the size of the idle
objects in the pool.
I think this is a good idea because it solves the deadlock issue
described in DBCP-65 when DBCP uses an evictor.
The most crude form of the decorator would implement returnObject
something like:
returnObject(Object obj) {
if (Math.random() < 0.01) { // 1% of the time
wrappedPool.invalidateObject(obj);
} else {
wrappedPool.returnObject(obj);
}
}
more intelligent code could take in to account the actual number if
active and idle pooled objects. Hopefully that conveys the idea I'm
thinking of.
This does have flaws in that it does require activity on the pool for
it to work because it wouldn't have it's own thread, but that is also
how it avoids the risk of deadlocks.
Anyone agree or disagree with me that this is a worthy feature.
More info at:
http://issues.apache.org/jira/browse/DBCP-65
http://issues.apache.org/jira/browse/POOL-86
--
Sandy McArthur
"He who dares not offend cannot be honest."
- Thomas Paine
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [pool][dbcp] trimming the pool size after load spikes
Posted by Phil Steitz <ph...@gmail.com>.
Sandy,
Sorry I missed this, which is unfortunate since I have been banging my
head on DBCP-65 for several hours over the last week. See comments
inline below.
On 10/31/06, Sandy McArthur <sa...@apache.org> wrote:
> Phil and others interested in Pool and DBCP,
>
> While working on resolving POOL-86 which is about finding a way to
> trim the pool size down after a load spike to try to minimize used
> resources during off peak load levels.
>
This is a reasonable requirement, IMO. Sometimes this happens after
dependent resource slowdowns as well as load spikes.
> I've suggested a decorator that wraps a pool and monitors it's usage
> and intercepts calls to returnObject and directs them to
> invalidateObject occasionally in order to shrink the size of the idle
> objects in the pool.
>
> I think this is a good idea because it solves the deadlock issue
> described in DBCP-65 when DBCP uses an evictor.
>
Can you explain exactly how this will solve DBCP-65?
> The most crude form of the decorator would implement returnObject
> something like:
>
> returnObject(Object obj) {
> if (Math.random() < 0.01) { // 1% of the time
> wrappedPool.invalidateObject(obj);
> } else {
> wrappedPool.returnObject(obj);
> }
> }
>
> more intelligent code could take in to account the actual number if
> active and idle pooled objects. Hopefully that conveys the idea I'm
> thinking of.
>
I like this idea, with the latter kind of implementation. It is
interesting to think about the performance implications of the crude
form under differing load profiles. It could hurt in some cases. Some
sort of rolling mean of idle connections or longest idle time would
probably be best to use (i.e., not just current data, but some measure
of how much headroom the pool has had recently).
> This does have flaws in that it does require activity on the pool for
> it to work because it wouldn't have it's own thread, but that is also
> how it avoids the risk of deadlocks.
>
Is there any really threadsafe way to do it otherwise? Unfortunately,
the activity requirement is bad because the time when you want the
benefit is precisely when it will be slow coming.
Phil
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org