Skip to content
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

Don't serialize returning connections to pool in background #982

merged 1 commit into from Apr 30, 2021


Copy link

Greatly improves latency for #979.

This was a bottleneck in highly concurrent applications that could generate unacceptably high latencies when waiting for a connection to be reset and returned to the pool.

Signed-off-by: Bradley Grainger <>
@bgrainger bgrainger linked an issue Apr 30, 2021 that may be closed by this pull request
Copy link

sonarcloud bot commented Apr 30, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Member Author

A test was run with wrk -t4 -c100 -d60s -R2000 --latency 'http://localhost:5000/...'

Legend: CR = ConnectionReset; DCR = DeferConnectionReset. Columns (left to right):

  • ConnectionReset=false should be the fastest, as it eliminates the reset work entirely
  • DeferConnectionReset=true is the behaviour of 1.2.x; should be slower due to extra work (resetting) when opening a connection
  • DeferConnectionReset=false is default behaviour in 1.3.x; lowers initial latency but can get very bad
  • This PR is the same settings as column 3, but with code to improve latency; it's extremely competitive with column 1 at the cost of increased concurrent connection usage to reset the connections in the background
  CR = false CR=true;DCR=true CR=true;DCR=false This PR
Max Connections 100 100 200 182
P50 19.07 27.60 18.82 18.77
P75 19.63 28.06 19.25 19.17
P90 20.43 28.59 19.74 19.58
P99 23.57 31.63 39.26 23.92
P99.9 35.04 38.14 164.99 36.64
P99.99 166.14 220.16 865.28 76.22
P99.999 230.01 247.55 1,150.00 235.65
P100 230.14 256.51 1,180.00 235.65

Copy link
Member Author

Fixed in 1.3.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

Connection pool discrepancies
1 participant