Increase KEEP_ALIVE_TIMEOUT default to 120 seconds#2670
Merged
Conversation
Sanic has used 5 second timeout to quickly close idle connections, for no particular reason, as idle connections use very little resources. This PR increases it to 80 seconds, slightly larger than Nginx default of 75 s, to avoid a problem with a request failing when Sanic has closed the connection but Nginx hasn't noticed. This should also improve practical performance on long latency connections, where reconnecting is expensive, and better fits typical user flow browsing pages with longer-than-5-second intervals. The root cause of the next request failing (i.e. connection not being properly terminated) should be looked at in more detail, but meanwhile this should be a useful workaround to keep the defaults working fluently, as well as to improve performance for the aforementioned reasons.
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #2670 +/- ##
=============================================
+ Coverage 88.887% 88.944% +0.057%
=============================================
Files 92 92
Lines 7001 7001
Branches 1194 1194
=============================================
+ Hits 6223 6227 +4
+ Misses 531 529 -2
+ Partials 247 245 -2
☔ View full report in Codecov by Sentry. |
Member
|
Tackle timeout overhaul in June? |
Member
Author
|
Yes, sounds good. This could be included as a workaround in 23.3 but probably better to avoid the hassle (docs update, release notes etc) and simply do it in 23.6 in one go with the simpler timeouts. |
Member
Author
|
Reopening for inclusion in 23.6 because we didn't get to do the bigger timeout revamping yet. |
ahopkins
reviewed
Jul 11, 2023
ahopkins
approved these changes
Jul 12, 2023
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sanic has used 5 second timeout to quickly close idle connections, for no particular reason, as idle connections use very little resources. This PR increases it to 80 seconds, slightly larger than Nginx default of 75 s, to avoid a problem with a request failing when Sanic has closed the connection but Nginx hasn't noticed. This should also improve practical performance on long latency connections, where reconnecting is expensive, and better fits typical user flow browsing pages with longer-than-5-second intervals.
The root cause of the next request failing (i.e. connection not being properly terminated) should be looked at in more detail, but meanwhile this should be a useful workaround to keep the defaults working fluently, as well as to improve performance for the aforementioned reasons.
Fix #2681