kmesh-net / kmesh

High Performance ServiceMesh Data Plane Based on Programmable Kernel
https://kmesh.net
Apache License 2.0
467 stars 70 forks source link

proposal: Locality Load Balancing for Kmesh #418

Open derekwin opened 5 months ago

derekwin commented 5 months ago

Why:

Currently, kmesh does not support locality topology-aware load balancing. The purpose of this proposal is to add locality-based topology-aware load balancing capabilities to kmesh, corresponding to locality load balancing in Istio.

Plan:

  1. Add new enum fields for the load balancing methods and implement the corresponding load balancing functions in cluster.h to support locality failover and locality weighted distribution. Refer to the implementation in the Istio control plane : https://github1s.com/istio/istio/blob/master/pilot/pkg/networking/core/loadbalancer/loadbalancer.go
  2. Implement the corresponding data structures combining parameters such as BalancingWeight, Priority, and Locality (new data structures may not be needed). Ensure that the load balancing functions have the capability to retrieve these parameters. The existing parameters are stored in the cluster's cache through the proto interface (in Go).

more detials: https://zrsnlqw1xd.feishu.cn/docx/Qpr6dtfe8olpBcx5HNscLotdn8c?from=from_copylink

hzxuzhonghu commented 5 months ago

Assume you mean the ads mode, right? And this is also missing in workload mode.

kwb0523 commented 5 months ago

@derekwin We need to prioritize implementation in the workload mode.

derekwin commented 5 months ago

Make adjustments to the proposal: focus on the implementation of locality load balancing under the workload model.

  1. The workload model requires implementing the corresponding load balancing logic in bpf\kmesh\workload\include\service.h, new load banlance handler function is similar to lb_random_handle.(locality failover, locality weighted distribution, ref
  2. Retrieve the load_balancing_weight and priority configurations from api/endpoint/endpoint.proto interface, and obtain the Locality configuration from api/workloadapi/workload.proto.
  3. Add the Locality load balance configuration field to pkg\controller\config.go.
  4. Add a new load balance type to api/cluster/cluster.proto.

more details: document

hzxuzhonghu commented 4 months ago

/assign @derekwin