You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Jon Moore <jo...@apache.org> on 2011/07/13 18:55:42 UTC

idle connections / connection reuse

Hi folks,

As a result of looking into the adaptive connection pools, I noticed
that the ConnPoolByRoute uses a queue to manage its open, reusable
connections, meaning the connections get used in a FIFO (round-robin)
fashion. One downside of this is that if the client currently has more
connections open than it really needs to keep up, it won't ever close
them.

For example, suppose during a burst of activity, the client ends up
with 3 open connections, but then settles down to a steady-state of
executing 2 requests per second, where each request takes 1 second on
average. In theory, the client could be getting away with just using
two connections here, but because the 3 existing connections are used
in a round-robin fashion, none of them are ever reclaimed and closed
by the "close idle connections" mechanism.

I think if the ConnPoolByRoute simply used a stack (LIFO) instead of a
queue that any excess capacity in terms of open connections would
eventually get reclaimed. I'm going to prototype this quickly, but
wanted to see if anyone else had any feedback.

Jon

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: idle connections / connection reuse

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2011-07-13 at 19:58 -0400, Jon Moore wrote:
> On Wed, Jul 13, 2011 at 2:18 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> > This does sounds like a bug which we should fix for the next release.
> 
> Ok, I have a patch that works. I'll open a JIRA ticket and get that
> committed shortly.
> 
> Jon
> 

Jon,

As soon as this problem is resolved I'll get down to cutting 4.1.2
release of HttpClient.

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: idle connections / connection reuse

Posted by Jon Moore <jo...@apache.org>.
On Wed, Jul 13, 2011 at 2:18 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> This does sounds like a bug which we should fix for the next release.

Ok, I have a patch that works. I'll open a JIRA ticket and get that
committed shortly.

Jon

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: idle connections / connection reuse

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2011-07-13 at 12:55 -0400, Jon Moore wrote:
> Hi folks,
> 
> As a result of looking into the adaptive connection pools, I noticed
> that the ConnPoolByRoute uses a queue to manage its open, reusable
> connections, meaning the connections get used in a FIFO (round-robin)
> fashion. One downside of this is that if the client currently has more
> connections open than it really needs to keep up, it won't ever close
> them.
> 
> For example, suppose during a burst of activity, the client ends up
> with 3 open connections, but then settles down to a steady-state of
> executing 2 requests per second, where each request takes 1 second on
> average. In theory, the client could be getting away with just using
> two connections here, but because the 3 existing connections are used
> in a round-robin fashion, none of them are ever reclaimed and closed
> by the "close idle connections" mechanism.
> 
> I think if the ConnPoolByRoute simply used a stack (LIFO) instead of a
> queue that any excess capacity in terms of open connections would
> eventually get reclaimed. I'm going to prototype this quickly, but
> wanted to see if anyone else had any feedback.
> 
> Jon
> 

This does sounds like a bug which we should fix for the next release.

Oleg 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org