-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reuse the oldest keep-alive connection first #9672
Conversation
Previously we would reuse the newest one which meant as more and more connections were cycled the first one in the list became more and more stale until it was more likely to drop
CodSpeed Performance ReportMerging #9672 will not alter performanceComparing Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #9672 +/- ##
=======================================
Coverage 98.66% 98.66%
=======================================
Files 116 116
Lines 35638 35638
Branches 4225 4225
=======================================
Hits 35164 35164
Misses 319 319
Partials 155 155
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Is it possible that's a deliberate decision to avoid keeping too many connections open? e.g. A quick burst opens up 3 connections, then going forward only 1 request is needed at a time, so the other 2 connections will get closed. Whereas this will stop connections from getting closed. If you have evidence this approach is better, I'm fine with it. Just checking it's thought through (and maybe a comment added to the code to explain the design choice). |
My original thought was that it might make sense to reuse the newest one since its less likely to be closed, but it seems more connections get reused in production with the FIFO approach. I still want to do more testing with this though before I move it forward. Since it conflicts with #9671 I've put it on the back burner as that one seems much more important to solve. |
FIFO sounds like a good strategy for me. |
78% connection reuse before |
On another system where there is more /10s polling 73% before |
So its a little bit more likely to reuse a connection. YMMV based on the server keep alive timeout. |
Backport to 3.11: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply afb5ebb on top of patchback/backports/3.11/afb5ebb912ebe1cf88e0d2c19d5f240ffb0b72ee/pr-9672 Backporting merged PR #9672 into master
🤖 @patchback |
(cherry picked from commit afb5ebb)
@bdraco, |
Sorry there is no snippet. I was profiling a few different Home Assistant instances to gauge the effect with a real world use case. |
The change is available in the 3.11.0 betas if you would like to give it a test |
If you do a callgrind, look at the number of |
Previously we would reuse the newest one which meant as more and more connections were cycled the first one in the list became more and more stale until it was more likely to drop
Change the order from LIFO to FIFO