forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upstream: introduce weighted locality as wrapper around endpoint's Lo…
…cality Currently Envoy::Upstream::StrictDnsClusterImpl::ResolveTarget when instantiated for every endpoint also creates a full copy of envoy::config::endpoint::v3::LocalityLbEndpoints the endpoint belongs to. Given the message contains all the endpoints defined for it this leads to exponential growth of consumed memory as the number of endpoints increases. Even though those copies of endpoints are not used. Instead of creating a copy of envoy::config::endpoint::v3::LocalityLbEndpoints introduce WeightedLocality class which is a wrapper around envoy::config::core::v3::Locality with priority and load balancing weight actually used in the upstream implementation. Signed-off-by: Dmitry Rozhkov <[email protected]>
- Loading branch information
Showing
7 changed files
with
85 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "common/upstream/weighted_locality.h" | ||
|
||
namespace Envoy { | ||
namespace Upstream { | ||
|
||
WeightedLocality::WeightedLocality( | ||
const envoy::config::endpoint::v3::LocalityLbEndpoints& locality_lb_endpoint) | ||
: is_weight_set_{locality_lb_endpoint.has_locality() && | ||
locality_lb_endpoint.has_load_balancing_weight()}, | ||
load_balancing_weight_{locality_lb_endpoint.load_balancing_weight().value()}, | ||
locality_{locality_lb_endpoint.locality()}, priority_{locality_lb_endpoint.priority()} {} | ||
|
||
} // namespace Upstream | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include "envoy/config/core/v3/base.pb.h" | ||
#include "envoy/config/endpoint/v3/endpoint_components.pb.h" | ||
|
||
namespace Envoy { | ||
namespace Upstream { | ||
|
||
// An endpoint's locality decorated with priority and weight. | ||
class WeightedLocality { | ||
public: | ||
WeightedLocality(const envoy::config::endpoint::v3::LocalityLbEndpoints& locality_lb_endpoint); | ||
|
||
bool isWeightSet() const { return is_weight_set_; } | ||
uint32_t loadBalancingWeight() const { return load_balancing_weight_; } | ||
const envoy::config::core::v3::Locality& locality() const { return locality_; } | ||
uint32_t priority() const { return priority_; } | ||
|
||
private: | ||
const bool is_weight_set_; | ||
const uint32_t load_balancing_weight_; | ||
const envoy::config::core::v3::Locality locality_; | ||
const uint32_t priority_; | ||
}; | ||
|
||
} // namespace Upstream | ||
} // namespace Envoy |