CFHTTP Connection pooling added in LDEV-1000 does not work
Description
Environment
Attachments
- 03 Apr 2021, 08:23 pm
- 03 Apr 2021, 10:20 am
- 03 Apr 2021, 10:20 am
- 27 Mar 2019, 06:23 pm
- 27 Mar 2019, 06:20 pm
relates to
Activity
Zac Spitzer 17 July 2022 at 20:54
Zac Spitzer 10 May 2021 at 09:51Edited
I like being able to get stats, but I think we should be careful about adding any extra overhead
i.e. being able to query to connection pool, rather than doing it per request
Also, we may wanna upgrade to HttpClient 5.0 before tuning against an older release?
http://hc.apache.org/httpcomponents-client-5.0.x/migration-guide/index.html
but let’s not overload this issue, create new ones
Xavier De Cock 10 May 2021 at 07:40
Back on the “root” ticket, i’m trying to find out a few things
So basically, I’m searching if we can get informations / statistics about the connection reuse to “attach” as meta in the response, and even if it’s possible to get some “pool wait time”.
What i’d like to do, is move the HttpClient responsibility entirely inside HTTP4ClientImpl, this would allow to avoid building a client on each request and win some more performances. i’m not sure we’ll be able to keep the exact same signatures though, so not sure if it might impact existing extensions. if they get the builder instead of use the client directly.
One thing positive here would be to be able to reuse clients as the creation of client seems to be a quite extensive job, what i need to find, is how to efficiently allow multiple clients to exists (based on the builder configuration) and yet avoid leaking memory
So, IMHO the next step would be :
update the Http.java to get the httpClient directly instead of the builder.
Find if we can expose connection reuse informations attached to the response.
Prepare structure to allow avoiding creating httpClient on eachRequest. (i suspect this should address the osgi overhead quite a bit)
Zac Spitzer 5 April 2021 at 14:23
script would be the same
http url="one-off-url" pooling="true|false";
Xavier De Cock 5 April 2021 at 07:35
For the ssl impact it's better as we reuse the connection and maybe the session keys in some case, reducing the number of roundtrip quite aggressively, moving to https was the reason i fixed that at lucee level
Details
Assignee
Michael OffnerMichael OffnerReporter
Brad WoodBrad WoodPriority
CriticalFix versions
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Sprint
None
Details
Details
Assignee
Reporter
Priority
Fix versions
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
In ticket https://luceeserver.atlassian.net/browse/LDEV-1000, connection pooling was implemented so repeated CFHTTP calls to the same endpoint could reuse a connection keep alive. However, there were no details placed on the ticket about how to enable or use it and the suggested options were not implemented.
I actually fired up Wireshark to sniff some packets and tested this today alongside the same HTTP request being sent from Postman as a comparison. My takeaway is I do not believe that Lucee is properly allowing HTTP keep alives to work and the connection is being closed after each HTTP request.
First, I made two consecutive HTTP requests to a URL (/main/index2) via Postman and you can see the captured packets from Wireshark here:
You can see that the connection is negotiated and then both HTTP calls reuse that connection when testing in Postman.
Next I hit a CF page that made a CFHTTP call to the same URL
<cfhttp url="http://foobar.ngrok.io/main/index2">
I then refreshed that page in my browser twice, firing off a single HTTP call each time.
This time, Wireshark showed two separate TCP streams, one for each CFHTTP call and each stream not only negotiated its own TCP connection but Lucee specifically CLOSED the connection after each use. Here are the captured packets from each stream.
I believe the issue may be related to this ticket https://luceeserver.atlassian.net/browse/LDEV-371 which specially added code in to close the connection. That seems like it is defeating the purpose of the connection pool.