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

RoundRobinLoadBalancer: better identify excess connections #2173

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

idelpivnitskiy
Copy link
Member

Motivation:

Cold start or traffic spikes can result in opening excess connections to
handle unexpected load. Current selection algorithm in
RoundRobinLoadBalancer attempts to pick a random connection. This
approach does not let to decrease number of open connections when
traffic stabilizes.

Modifications:

Introduce linearSearchSpace configuration option for
RoundRobinLoadBalancerFactory to start a linear search before falling
back to a random selection.

Result:

Allows configuring more predictable selection of the connection. When
configured with IDLE_TIMEOUT socket option, helps to reduce the number
of connections that can serve multiplexed or pipelined requests.
Default value of 16 has no performance impact on non-pipelined HTTP/1.1
connections, but significantly reduces latencies for HTTP/2 requests and
number of open HTTP/2 connections. For 1024 concurrent HTTP/2 requests
p99 latency drops down 2.5x times without offloading and 4x with offloading,
number of open connections goes down from ~256 to <10.

Motivation:

Cold start or traffic spikes can result in opening excess connections to
handle unexpected load. Current selection algorithm in
`RoundRobinLoadBalancer` attempts to pick a random connection. This
approach does not let to decrease number of open connections when
traffic stabilizes.

Modifications:

Introduce `linearSearchSpace` configuration option for
`RoundRobinLoadBalancerFactory` to start a linear search before falling
back to a random selection.

Result:

Allows configuring more predictable selection of the connection. When
configured with `IDLE_TIMEOUT` socket option, helps to reduce number of
connections that can serve multiplexed or pipelined requests.
Default value of 16 has no performance impact on non-pipelined HTTP/1.1
connections, but significantly reduces latencies for HTTP/2 requests and
number of open HTTP/2 connections.
Copy link
Contributor

@tkountis tkountis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - nice trick

@idelpivnitskiy idelpivnitskiy merged commit 125524c into apple:main Apr 6, 2022
@idelpivnitskiy idelpivnitskiy deleted the rrlb branch April 6, 2022 21:24
@chemicL
Copy link
Contributor

chemicL commented Apr 8, 2022

Great improvement, congratulations!

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

Successfully merging this pull request may close these issues.

3 participants