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

Implement locality/priority based load balancing #5610

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jrhee17
Copy link
Contributor

@jrhee17 jrhee17 commented Apr 15, 2024

Motivation:

This pull request attempts to implement the default EdfLoadBalancerBase which is the default load balancer used in envoy. Most load balancer implementations in envoy derive from this base class.

The basic load balancer supports locality weighted load balancing and priority levels.

Note that not all functionality (namely zone aware load balancing, etc..) have been implemented for simplicity.
Additionally, SubsetLoadBalancer has not been implemented in this PR for easier reviewing. The previous SubsetLoadBalancer will be replaced in the next (and final) pull request.

This pull request mostly focuses on updating the LoadBalancer state when a ClusterSnapshot is updated.
The flow is as follows:

  1. ClusterEntry#accept is called, which indicates a ClusterSnapshot has been updated
  2. A PriorityStateManager computes endpoints per priority and locality.
  1. A PrioritySet is created. This PrioritySet contains a map of Integer -> HostSet where a HostSet contains host information for each health/locality.
  1. A DefaultLbStateFactory is created which creates a LbState for the DefaultLoadBalancer. A LbState is a convenience object used to avoid potential race conditions. The LbState is replaced atomically from the perspective of DefaultLoadBalancer.
  1. Lastly, the load balancer chooses a HostSource, and subsequently a host from the selected HostSet

ref: #5450

Modifications:

  • ClusterEntry now creates a PrioritySet for each ClusterSnapshot update
    • In order to create a PrioritySet, utility classes PriorityStateManager, PriorityState, HostSet, UpdateHostsParam have been created.
    • Utility classes EndpointUtil, EndpointGroupUtil have been created
  • DefaultLoadBalancer has been introduced. The functionality of this LoadBalancer is equivalent to EdfLoadBalancer.
  • DefaultLbStateFactory has been introduced to facilitate creating a state for DefaultLoadBalancer. The LbState created by DefaultLbStateFactory is intended to be updated atomically from the perspective of DefaultLoadBalancer.

Result:

  • Priority and locality based load balancing is now available for XdsEndpointGroup

@jrhee17 jrhee17 added this to the 1.29.0 milestone Apr 15, 2024
@jrhee17 jrhee17 marked this pull request as ready for review April 15, 2024 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant