You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Programmer <de...@gmail.com> on 2013/09/20 17:48:20 UTC
Commons Pooling request queue algorithm?
Hi,
We use apache commons pooling 1.6 in our enterprise application to pool LDAP
connections. If the number of active connections in the pool is exhausted,
the API is set to wait for 5 seconds before rejecting a connection request.
Now can someone please clarify about the order in which the connection
object requests are served by the API at run time? Is it FIFO - by which I
mean that the worker thread that requested for an active connection from the
exhausted pool will get the first preference when a new connection object
becomes available? Or is it LIFO, which is the vice versa?
Please lemme know if I should clarify this further. Any light on this
behavior is greatly appreciated. :)
- Programmer.
--
View this message in context: http://apache-commons.680414.n4.nabble.com/Commons-Pooling-request-queue-algorithm-tp4653914.html
Sent from the Commons - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [pool] Re: Commons Pooling request queue algorithm?
Posted by Phil Steitz <ph...@gmail.com>.
On 9/20/13 10:42 AM, Programmer wrote:
> Thanks Phil.
>
> I was interested to know about the 'fairness' of the connection distribution
> from the client perspective. :)
OK. Sorry I did not get the question at first. Let me explain a
little better how the 1.5.x / 1.6 servicing algorithm works, so you
understand what I mean by "mostly" fair. When borrowObject requests
arrive, they are assigned "latches" that go onto an "allocation
queue." The queue is worked in latch-creation order (so
FIFO/fair). "Working" the queue consists of allocating returned
objects to latches and/or issuing object creation permits to
latches. When the pool is configured to wait when exhausted,
waiting threads tell their latches to wait and the latches get
notified when they have been assigned returned objects or when they
have been given object creation permits. Creation permits get
issued when the pool is warming up or when due to maxIdle config or
validation failures the pool destroys objects, creating capacity for
new ones <side-rant>This is expensive and defeats pooling benefit,
so config / environment should be tuned to avoid too much of it
</side-rant>. Threads holding latches that get creation permits
invoke - so have to wait for - the factory methods to create the
instances, so it is possible that "lucky" threads that get to
perform this duty end up completing after successors to them have
been served, because returns may happen while they are waiting on
the factory makeObject method to complete.
Phil
>
>
>
> --
> View this message in context: http://apache-commons.680414.n4.nabble.com/Commons-Pooling-request-queue-algorithm-tp4653914p4653919.html
> Sent from the Commons - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [pool] Re: Commons Pooling request queue algorithm?
Posted by Programmer <de...@gmail.com>.
Thanks Phil.
I was interested to know about the 'fairness' of the connection distribution
from the client perspective. :)
--
View this message in context: http://apache-commons.680414.n4.nabble.com/Commons-Pooling-request-queue-algorithm-tp4653914p4653919.html
Sent from the Commons - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
[pool] Re: Commons Pooling request queue algorithm?
Posted by Phil Steitz <ph...@gmail.com>.
On 9/20/13 8:48 AM, Programmer wrote:
> Hi,
>
> We use apache commons pooling 1.6 in our enterprise application to pool LDAP
> connections. If the number of active connections in the pool is exhausted,
> the API is set to wait for 5 seconds before rejecting a connection request.
>
> Now can someone please clarify about the order in which the connection
> object requests are served by the API at run time? Is it FIFO - by which I
> mean that the worker thread that requested for an active connection from the
> exhausted pool will get the first preference when a new connection object
> becomes available? Or is it LIFO, which is the vice versa?
>
> Please lemme know if I should clarify this further. Any light on this
> behavior is greatly appreciated. :)
I am not sure I understand the question. If you are asking whether
or not the pool is fair from the client perspective, the answer is
"mostly yes" - i.e., the 1.5.x/1.6 implements a servicing model that
aims to provide service to waiting threads in close to arrival
order. This is not a hard contract; however, and it cannot be
counted on in all cases. If you are asking about how the pool
serves objects, the LIFO/FIFO behavior is configurable. See the
get/setLifo methods in the javadoc. The default is LIFO, meaning
that the most recently returned object to the pool will be the first
to returned by borrowObject.
Phil
>
> - Programmer.
>
>
>
> --
> View this message in context: http://apache-commons.680414.n4.nabble.com/Commons-Pooling-request-queue-algorithm-tp4653914.html
> Sent from the Commons - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org