-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor service load balancer to support different strategies
This is a change to add the "power of two random choices" load balancing strategy to the service's load balancer. This change does not actually start using the new strategy, and is backwards incompatable, but intended to start a design-review. To fully add support, many tests will need to be updated, so this change is meant to highlight the core changes to support the new strategy. Currently the only load balancing strategy available within traefik is (weighted) round robin. While this is a good strategy in general, it can be problematic if one or more of the backends is getting overloaded. There are many load balancing strategies, but the "power-of-two-random-choices" algorithm has some good properties that make it a good general use algorithm. Specifically some of the benefits include: - reducing the total number of requests to slower backends - constant time backend picking (in the general case) - reduced "herd behaviour" compared to e.g. "least connections" load balancing. The algorithm works by taking two backends at random, and choosing the backend that has the fewest in-flight requests. In order to do this, we have to track the number of in-flight requests each backend is currently processing. The aim of this change is to demonstrate that this new load balancing strategy can be added with minimal changes, and reusing a lot of the existing load balancing code by factoring out the explicit strategy into an interface. In order to do this, the wrr package was removed, and the existing LoadBalancer was moved to the parent directory: the loadbalancer package. There are many strategies that can be used for load balancing, many of which require "extrinsic" information, such as the CPU load on the backends. This change is not meant to open the door for adding such strategies, but attempts to add an effective load balancing strategy with low cost to the codebase.
- Loading branch information
=
committed
Mar 20, 2024
1 parent
c1ef742
commit c92a1ed
Showing
6 changed files
with
559 additions
and
143 deletions.
There are no files selected for viewing
This file contains 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
Oops, something went wrong.