You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by "Sangjin Lee (JIRA)" <ji...@apache.org> on 2007/12/07 19:33:43 UTC

[jira] Commented: (GERONIMO-3686) AsyncHttpClient does not reuse connection even if connections are persistent

    [ https://issues.apache.org/jira/browse/GERONIMO-3686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12549506 ] 

Sangjin Lee commented on GERONIMO-3686:
---------------------------------------

Here is a proposal on how the connection reuse may work.

- Once an IoSession is opened and used successfully for a request-response cycle, at the end of the response processing, we cache the IoSession.
- The sessions are stored keyed by the remote peer (host + port).  For the given remote peer, sessions should be cached in a FIFO manner.  A non-blocking queue might be a good candidate.
- When sessions close for any reason (i.e. when the handler gets notified via sessionClosed()), we remove the session from the cache.
- On sendRequest(), AsyncHttpClient should first check the session cache to see if there is an available active session.  It should also check if the session is still connected.  If not, it can keep peeling the queue until it finds one or it exhausts the queue.
- If it fails to find a connected cached session, then it opens a new connection.
- The keep-alive config on AsyncHttpClient should provide a different behavior.  If keepAlive is set to false, then AsyncHttpClient should always open a new connection, ignoring the session cache.  Furthermore, if keepAlive is set to false, it should add a Connection: close header to make it explicit.
- The session cache may be global, and should be shared safely by multiple instances of AsyncHttpClient.

Thoughts?  Comments?



> AsyncHttpClient does not reuse connection even if connections are persistent
> ----------------------------------------------------------------------------
>
>                 Key: GERONIMO-3686
>                 URL: https://issues.apache.org/jira/browse/GERONIMO-3686
>             Project: Geronimo
>          Issue Type: Bug
>      Security Level: public(Regular issues) 
>          Components: AsyncHttpClient
>    Affects Versions: 1.x
>            Reporter: Sangjin Lee
>
> Each time AsyncHttpClient.sendRequest() is called, a new TCP connection is opened, even though connections may be kept alive per HTTP spec.  If connections are kept open, they should be reused for more requests.

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