-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http: prefetch for upstreams #14143
http: prefetch for upstreams #14143
Changes from 2 commits
377a655
a3f873e
03d25da
0de2a56
00d0506
7f58cb6
800fb46
280b655
8bc15af
963803b
a130c58
47b4b7e
f4619e3
84882f2
568ac1c
5f3ef8a
228f441
7f391a9
575636e
ff6aba8
dbb54a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,12 @@ static const std::string RuntimeZoneEnabled = "upstream.zone_routing.enabled"; | |
static const std::string RuntimeMinClusterSize = "upstream.zone_routing.min_cluster_size"; | ||
static const std::string RuntimePanicThreshold = "upstream.healthy_panic_threshold"; | ||
|
||
bool tooManyPreconnects(size_t num_preconnect_picks, uint32_t healthy_hosts) { | ||
// Currently we only allow the number of preconnected connections to equal the | ||
// number of healthy hosts. | ||
return num_preconnect_picks >= healthy_hosts; | ||
} | ||
|
||
// Distributes load between priorities based on the per priority availability and the normalized | ||
// total availability. Load is assigned to each priority according to how available each priority is | ||
// adjusted for the normalized total availability. | ||
|
@@ -780,7 +786,7 @@ void EdfLoadBalancerBase::refresh(uint32_t priority) { | |
} | ||
|
||
HostConstSharedPtr EdfLoadBalancerBase::peekAnotherHost(LoadBalancerContext* context) { | ||
if (stashed_random_.size() >= total_healthy_hosts_) { | ||
if (tooManyPreconnects(stashed_random_.size(), total_healthy_hosts_)) { | ||
return nullptr; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is 1 the right max ratio of prefetched connections to healthy hosts? I imagine that when the number of endpoints is small it would be beneficial to set this ratio > 1.0, specially if host weights are not all equal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one isn't a ratio thing - we currently cap #prefetches to the number of healthy hosts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there plans to relax that restriction? It seems to get in the way of getting to a fixed number of connections in cases where the number of healthy upstreams is less than the desired number of connections. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as needed. Right now I was aiming at the server side, where for low QPS you'd genreally prefetch a few, and for high qps you'd want per upstream but as we move towards mobile if we only have a single upstream per endpoint we'd want to have more than 1 prefetch. |
||
|
||
|
@@ -869,7 +875,7 @@ HostConstSharedPtr LeastRequestLoadBalancer::unweightedHostPick(const HostVector | |
} | ||
|
||
HostConstSharedPtr RandomLoadBalancer::peekAnotherHost(LoadBalancerContext* context) { | ||
if (stashed_random_.size() >= total_healthy_hosts_) { | ||
if (tooManyPreconnects(stashed_random_.size(), total_healthy_hosts_)) { | ||
return nullptr; | ||
} | ||
return peekOrChoose(context, true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm feeling very dense, but I'm having a really hard time with this logic. Two things:
shouldCreateNewConnection
and add a bunch more comments? I think that would help me. (Same question about +1 in that function)