Skip to content

feat: As a user, I want to the load balancer to support subset matching, so that I can quickly setup multiple service lanes #12487

@jizhuozhi

Description

@jizhuozhi

Description

As a user, I want to the load balancer to support subset matching, so that I can quickly setup multiple service lanes

This feature can be considered a simplified version of Envoy's subsets (https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/subsets).

After discovery retrieves the node list from the registry, the load balancing algorithm partitions the node list into subsets based on configured metadata keys. The requester can include a specific header (such as X-Env) or a set of headers in the request. If their values match the registered metadata, the corresponding subset will be used.

This is essential for microservice testing, and is actually part of implementing service swimlanes. I've previously implemented a tag-based subset algorithm in Kitex (ByteDance's microservice framework) (https://github.com/kitex-contrib/loadbalance-tagging/blob/main/tagging.go), and at my current employer, I've implemented a client-side load balancing algorithm based on grpc-go that's closer to Envoy subset (because our online service links are extremely long and latency-sensitive, we can't use Envoy proxies and instead use a fat client approach). However, we now need to implement swimlane splitting from the gateway.

This is our ideal swimlane diagram
Image

However, the complete Envoy subset strategy is very complex, so we simplified it when implementing it. This is our final proto schema, it's enough.

message Subset {
  enum LbSubsetFallbackPolicy {
    NO_FALLBACK = 0;
    ANY_ENDPOINT = 1;
    DEFAULT_SUBSET = 2;
  }
  message LbSubsetSelector {
    repeated string keys = 1;
  }
  LbSubsetFallbackPolicy fallback_policy = 1;
  google.protobuf.Struct default_subset = 2;
  repeated LbSubsetSelector subset_selectors = 3;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions