hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michajlo Matijkiw (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HTTPCLIENT-1000) Configure Maximum Connection Lifetimes
Date Wed, 22 Sep 2010 20:11:01 GMT

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1000?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Michajlo Matijkiw updated HTTPCLIENT-1000:

    Attachment: connection_ttl.patch

Looking into the code some more it would appear that just changing how BasicPoolEntry#expiry
is used is sufficient.  Connections appear to be released back to the pool after requests,
and are cleaned up based on expiry, where expiry is how long the connection may remain open
for and in the pool after use.  By setting expiry to be the lesser of this definition, and
BasicPoolEntry#created+TTL, we can bound how long connections are maintained for.

This patch contains the following changes:
 - ThreadSafeClientConnManager, ConnPoolByRoute, and BasicPoolEntry have an additional constructor
with two extra arguments specifying connection TTL and TimeUnit.  TTL defaults to -1 implying
infinity, the values are propogated down to BasicPoolEntry
 - BasicPoolEntry contains updated logic to caclulate expiry
 - Unit test to verify behavior

Since TTL defaults to -1 which implies "infinity", this patch should have no effect if the
optional arguments are not provided to the constructors.

This patch is submitted with the permission of my employer.


> Configure Maximum Connection Lifetimes
> --------------------------------------
>                 Key: HTTPCLIENT-1000
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1000
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: HttpClient
>            Reporter: Michajlo Matijkiw
>         Attachments: connection_ttl.patch
> Provide a means of configuring a maximum lifetime for HttpClient connections.  Currently,
it would appear as long as a connection is used it may persist indefinitely.
> This would be useful for situations where HttpClient needs to react to DNS changes, such
as the following situation that may occur when using DNS load balancing:
>  - HttpClient maintains connections to example.com which resolves to IP A
>  - Machine at IP A fails, and example.com now resolves to backup machine at IP B
>  - Since IP A is failing, connections are destroyed, and new connections are made to
>  - Machine at IP A recovers, but HttpClient maintains connections to IP B since the connections
are still healthy
> The desired behavior would be that connections to IP B will reach their connection lifetime,
and new connections could be created back to IP A according to the updated DNS settings.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

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

View raw message