perf: raise the default connection pool size from 5 to 100 - #113
Merged
Merged
Conversation
ConnectionPool kept only 5 idle connections, so connections opened for a burst were closed and the next burst redid the TCP and TLS handshakes.
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.
Problem
The SDK's calls are synchronous
execute()calls, whichDispatcher.maxRequestsPerHostdoes not limit, so concurrency was never capped at 5. ButConnectionPool(5, ...)kept only 5 idle connections, so after a burst every other connection was closed and the next burst redid the TCP and TLS handshakes.Solution
DEFAULT_MAX_CONNS_PER_HOSTfrom 5 to 100, so up to 100 connections stay warm for reuse. Idle connections still close after 55s.enqueue()calls.How to verify
./gradlew test --tests 'io.getstream.StreamHTTPClientTest'testDefaultPoolKeepsBurstConnectionsWarmruns 10 concurrent requests against a local server and asserts that all 10 connections stay idle in the pool. With the old default it fails withexpected: <10> but was: <5>.