From 088a3436fe5ea96129afd3b24e5fdfc813ab0b77 Mon Sep 17 00:00:00 2001 From: "data-plane-api(CircleCI)" Date: Wed, 2 Sep 2020 16:51:25 +0000 Subject: [PATCH] upstream: Optimize subset_lb for case of a single host per subset (#12594) This can be used in similar situations to maglev/ring, but can be used when the host selection must remain the same for existing sessions even if more hosts are added to the cluster. In a test with 1500 endpoints, updating 50 (remove 50, add 50 different ones) took: without new setting: ~500ms with new setting (this PR): ~4ms Signed-off-by: Greg Greenway Mirrored from https://github.com/envoyproxy/envoy @ 724df08c329c8270509e2a8568be90fd43d597c1 --- envoy/config/cluster/v3/cluster.proto | 14 ++++++++++++++ envoy/config/cluster/v4alpha/cluster.proto | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/envoy/config/cluster/v3/cluster.proto b/envoy/config/cluster/v3/cluster.proto index 8841043f..75e95acf 100644 --- a/envoy/config/cluster/v3/cluster.proto +++ b/envoy/config/cluster/v3/cluster.proto @@ -246,6 +246,20 @@ message Cluster { // List of keys to match with the weighted cluster metadata. repeated string keys = 1; + // Selects a mode of operation in which each subset has only one host. This mode uses the same rules for + // choosing a host, but updating hosts is faster, especially for large numbers of hosts. + // + // If a match is found to a host, that host will be used regardless of priority levels, unless the host is unhealthy. + // + // Currently, this mode is only supported if `subset_selectors` has only one entry, and `keys` contains + // only one entry. + // + // When this mode is enabled, configurations that contain more than one host with the same metadata value for the single key in `keys` + // will use only one of the hosts with the given key; no requests will be routed to the others. The cluster gauge + // :ref:`lb_subsets_single_host_per_subset_duplicate` indicates how many duplicates are + // present in the current configuration. + bool single_host_per_subset = 4; + // The behavior used when no endpoint subset matches the selected route's // metadata. LbSubsetSelectorFallbackPolicy fallback_policy = 2 diff --git a/envoy/config/cluster/v4alpha/cluster.proto b/envoy/config/cluster/v4alpha/cluster.proto index 7c9e266c..fde0b1f0 100644 --- a/envoy/config/cluster/v4alpha/cluster.proto +++ b/envoy/config/cluster/v4alpha/cluster.proto @@ -249,6 +249,20 @@ message Cluster { // List of keys to match with the weighted cluster metadata. repeated string keys = 1; + // Selects a mode of operation in which each subset has only one host. This mode uses the same rules for + // choosing a host, but updating hosts is faster, especially for large numbers of hosts. + // + // If a match is found to a host, that host will be used regardless of priority levels, unless the host is unhealthy. + // + // Currently, this mode is only supported if `subset_selectors` has only one entry, and `keys` contains + // only one entry. + // + // When this mode is enabled, configurations that contain more than one host with the same metadata value for the single key in `keys` + // will use only one of the hosts with the given key; no requests will be routed to the others. The cluster gauge + // :ref:`lb_subsets_single_host_per_subset_duplicate` indicates how many duplicates are + // present in the current configuration. + bool single_host_per_subset = 4; + // The behavior used when no endpoint subset matches the selected route's // metadata. LbSubsetSelectorFallbackPolicy fallback_policy = 2