[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_12551008 ] Rick McGuire commented on GERONIMO-3686: Oops, sorry. I saw the new files but forgot to do the svn add before the commit. The files are there now: Committed revision 603657. > 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 >Assignee: Rick McGuire > Attachments: 3686.patch > > > 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.
[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_12551004 ] Sangjin Lee commented on GERONIMO-3686: --- It seems that a couple of added files were not committed: src/test/java/org/apache/ahc/ConnectionReuseTest.java src/main/java/org/apache/ahc/codec/SessionCache.java The build must be broken without them... Could you please add them? Thanks. > 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 >Assignee: Rick McGuire > Attachments: 3686.patch > > > 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.
[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_12550779 ] Sangjin Lee commented on GERONIMO-3686: --- I'm making a small correction to the patch, and will upload a revised version shortly. The issue is that I forgot to add an additional configuration option called reuseConnection. Connection reuse is different than the SO_KEEPALIVE on the socket... > 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 > Attachments: 3686.patch > > > 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.
[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_12549522 ] Sangjin Lee commented on GERONIMO-3686: --- I am also adding a few more convenience methods on HttpMessage on handling HTTP headers as part of this. They include: String getHeader(String name); String[] getHeaders(String name); // returns all of them in case there are multiple under the same name which can happen (e.g. Set-Cookie) void removeHeader(String name); void setHeader(String name, String value); // overwrites existing instead of adding to them > 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.
[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_12549518 ] Sangjin Lee commented on GERONIMO-3686: --- Yes, actually in the implementation I've written the session validation occurs inside the session cache, and not by the caller. Agreed on the container types, that's what I've been using: ConcurrentHashMap/ConcurrentLinkedQueue. One cannot live without them. :) > 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.
[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_12549510 ] Jeff Genender commented on GERONIMO-3686: - Cool stuff. Yep...FIFO would be the way I would do the queues. A ConcurrentLinkedQueue is perfect for this. For the container that holds these queues, a ConcurrentHashmap would be great. Instead of the sendRequest() checking the connection validation, why not make this a facet of the checking out. In fact this whole thing could be part of a connection manager/connection cache that will return one if it exists (an is valid) or creates it if one doesn't. The ideas look very sound and looks good to me. > 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.
[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.
