Skip to content

Commit ba2fab0

Browse files
committed
Revert "fix: only enable full scan when enable_full_scan is set explicitly forleast request lb (#30794)"
This reverts commit e93e556. Revert "Fix least request lb not fair (#29873)" This reverts commit 3ea2bc4. restore api Signed-off-by: Kuat Yessenov <kuat@google.com> fix merge Signed-off-by: Kuat Yessenov <kuat@google.com>
1 parent 74761ee commit ba2fab0

File tree

6 files changed

+3
-87
lines changed

6 files changed

+3
-87
lines changed

api/envoy/extensions/load_balancing_policies/least_request/v3/least_request.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ message LeastRequest {
6060
// Configuration for local zone aware load balancing or locality weighted load balancing.
6161
common.v3.LocalityLbConfig locality_lb_config = 4;
6262

63+
// [#not-implemented-hide:]
6364
// Configuration for performing full scan on the list of hosts.
6465
// If this configuration is set, when selecting the host a full scan on the list hosts will be
6566
// used to select the one with least requests instead of using random choices.

changelogs/current.yaml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ minor_behavior_changes:
2525
change: |
2626
uses http async client to fetch the credentials from EC2 instance metadata and ECS task metadata providers instead of libcurl
2727
which is deprecated. To revert this behavior set ``envoy.reloadable_features.use_libcurl_to_fetch_aws_credentials`` to true.
28-
- area: upstream
29-
change: |
30-
Fixed a reported issue (https://github.com/envoyproxy/envoy/issues/11004) that causes the Least
31-
Request load balancer policy to be unfair when the number of hosts are very small, when the number
32-
of hosts is smaller than the choice_count, instead of randomly selection hosts from the list, we
33-
perform a full scan on it to choose the host with least requests.
3428
- area: local_rate_limit
3529
change: |
3630
Added new configuration field :ref:`rate_limited_as_resource_exhausted
@@ -112,13 +106,6 @@ new_features:
112106
change: |
113107
Added :ref:`the Basic Auth filter <envoy_v3_api_msg_extensions.filters.http.basic_auth.v3.BasicAuth>`, which can be used to
114108
authenticate user credentials in the HTTP Authentication heaer defined in `RFC7617 <https://tools.ietf.org/html/rfc7617>`_.
115-
- area: upstream
116-
change: |
117-
Added :ref:`enable_full_scan <envoy_v3_api_msg_extensions.load_balancing_policies.least_request.v3.LeastRequest>`
118-
option to the least requested load balancer. If set to true, Envoy will perform a full scan on the list of hosts
119-
instead of using :ref:`choice_count
120-
<envoy_v3_api_msg_extensions.load_balancing_policies.least_request.v3.LeastRequest>`
121-
to select the hosts.
122109
- area: stats
123110
change: |
124111
added :ref:`per_endpoint_stats <envoy_v3_api_field_config.cluster.v3.TrackClusterStats.per_endpoint_stats>` to get some metrics

docs/root/intro/arch_overview/upstream/load_balancing/load_balancers.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ same or different weights.
3838
approach is nearly as good as an O(N) full scan). This is also known as P2C (power of two
3939
choices). The P2C load balancer has the property that a host with the highest number of active
4040
requests in the cluster will never receive new requests. It will be allowed to drain until it is
41-
less than or equal to all of the other hosts. The number of hosts chosen can be changed by setting
42-
``choice_count``.
43-
41+
less than or equal to all of the other hosts.
4442
* *all weights not equal*: If two or more hosts in the cluster have different load balancing
4543
weights, the load balancer shifts into a mode where it uses a weighted round robin schedule in
4644
which weights are dynamically adjusted based on the host's request load at the time of selection.

source/common/upstream/load_balancer_impl.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,24 +1299,6 @@ HostConstSharedPtr LeastRequestLoadBalancer::unweightedHostPick(const HostVector
12991299
const HostsSource&) {
13001300
HostSharedPtr candidate_host = nullptr;
13011301

1302-
// Do full scan if it's required explicitly.
1303-
if (enable_full_scan_) {
1304-
for (const auto& sampled_host : hosts_to_use) {
1305-
if (candidate_host == nullptr) {
1306-
// Make a first choice to start the comparisons.
1307-
candidate_host = sampled_host;
1308-
continue;
1309-
}
1310-
1311-
const auto candidate_active_rq = candidate_host->stats().rq_active_.value();
1312-
const auto sampled_active_rq = sampled_host->stats().rq_active_.value();
1313-
if (sampled_active_rq < candidate_active_rq) {
1314-
candidate_host = sampled_host;
1315-
}
1316-
}
1317-
return candidate_host;
1318-
}
1319-
13201302
for (uint32_t choice_idx = 0; choice_idx < choice_count_; ++choice_idx) {
13211303
const int rand_idx = random_.random() % hosts_to_use.size();
13221304
const HostSharedPtr& sampled_host = hosts_to_use[rand_idx];

source/common/upstream/load_balancer_impl.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,7 @@ class LeastRequestLoadBalancer : public EdfLoadBalancerBase {
710710
least_request_config.has_active_request_bias()
711711
? absl::optional<Runtime::Double>(
712712
{least_request_config.active_request_bias(), runtime})
713-
: absl::nullopt),
714-
enable_full_scan_(
715-
PROTOBUF_GET_WRAPPED_OR_DEFAULT(least_request_config, enable_full_scan, false)) {
713+
: absl::nullopt) {
716714
initialize();
717715
}
718716

@@ -748,7 +746,6 @@ class LeastRequestLoadBalancer : public EdfLoadBalancerBase {
748746
double active_request_bias_{};
749747

750748
const absl::optional<Runtime::Double> active_request_bias_runtime_;
751-
const bool enable_full_scan_{};
752749
};
753750

754751
/**

test/common/upstream/load_balancer_impl_test.cc

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,55 +2880,6 @@ TEST_P(LeastRequestLoadBalancerTest, PNC) {
28802880
EXPECT_EQ(hostSet().healthy_hosts_[3], lb_5.chooseHost(nullptr));
28812881
}
28822882

2883-
TEST_P(LeastRequestLoadBalancerTest, FullScan) {
2884-
hostSet().healthy_hosts_ = {makeTestHost(info_, "tcp://127.0.0.1:80", simTime()),
2885-
makeTestHost(info_, "tcp://127.0.0.1:81", simTime()),
2886-
makeTestHost(info_, "tcp://127.0.0.1:82", simTime()),
2887-
makeTestHost(info_, "tcp://127.0.0.1:83", simTime()),
2888-
makeTestHost(info_, "tcp://127.0.0.1:84", simTime())};
2889-
hostSet().hosts_ = hostSet().healthy_hosts_;
2890-
hostSet().runCallbacks({}, {}); // Trigger callbacks. The added/removed lists are not relevant.
2891-
2892-
hostSet().healthy_hosts_[0]->stats().rq_active_.set(4);
2893-
hostSet().healthy_hosts_[1]->stats().rq_active_.set(3);
2894-
hostSet().healthy_hosts_[2]->stats().rq_active_.set(2);
2895-
hostSet().healthy_hosts_[3]->stats().rq_active_.set(1);
2896-
hostSet().healthy_hosts_[4]->stats().rq_active_.set(5);
2897-
2898-
// Creating various load balancer objects with different choice configs.
2899-
envoy::extensions::load_balancing_policies::least_request::v3::LeastRequest lr_lb_config;
2900-
lr_lb_config.mutable_choice_count()->set_value(2);
2901-
// Enable full table scan on hosts
2902-
lr_lb_config.mutable_enable_full_scan()->set_value(true);
2903-
common_config_.mutable_healthy_panic_threshold()->set_value(0);
2904-
2905-
LeastRequestLoadBalancer lb_2{priority_set_, nullptr, stats_, runtime_,
2906-
random_, 1, lr_lb_config, simTime()};
2907-
lr_lb_config.mutable_choice_count()->set_value(3);
2908-
LeastRequestLoadBalancer lb_3{priority_set_, nullptr, stats_, runtime_,
2909-
random_, 1, lr_lb_config, simTime()};
2910-
lr_lb_config.mutable_choice_count()->set_value(4);
2911-
LeastRequestLoadBalancer lb_4{priority_set_, nullptr, stats_, runtime_,
2912-
random_, 1, lr_lb_config, simTime()};
2913-
lr_lb_config.mutable_choice_count()->set_value(6);
2914-
LeastRequestLoadBalancer lb_6{priority_set_, nullptr, stats_, runtime_,
2915-
random_, 1, lr_lb_config, simTime()};
2916-
2917-
// random is called only once every time and is not to select the host.
2918-
2919-
EXPECT_CALL(random_, random()).WillOnce(Return(9999));
2920-
EXPECT_EQ(hostSet().healthy_hosts_[3], lb_2.chooseHost(nullptr));
2921-
2922-
EXPECT_CALL(random_, random()).WillOnce(Return(9999));
2923-
EXPECT_EQ(hostSet().healthy_hosts_[3], lb_3.chooseHost(nullptr));
2924-
2925-
EXPECT_CALL(random_, random()).WillOnce(Return(9999));
2926-
EXPECT_EQ(hostSet().healthy_hosts_[3], lb_4.chooseHost(nullptr));
2927-
2928-
EXPECT_CALL(random_, random()).WillOnce(Return(9999));
2929-
EXPECT_EQ(hostSet().healthy_hosts_[3], lb_6.chooseHost(nullptr));
2930-
}
2931-
29322883
TEST_P(LeastRequestLoadBalancerTest, WeightImbalance) {
29332884
hostSet().healthy_hosts_ = {makeTestHost(info_, "tcp://127.0.0.1:80", simTime(), 1),
29342885
makeTestHost(info_, "tcp://127.0.0.1:81", simTime(), 2)};

0 commit comments

Comments
 (0)