-
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
Adaptive concurrency no-op implementation #7819
Conversation
Signed-off-by: Tony Allen <[email protected]>
Signed-off-by: Tony Allen <[email protected]>
Signed-off-by: Tony Allen <[email protected]>
Signed-off-by: Tony Allen <[email protected]>
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.
This was modeled after the HTTP filter example repo, so apologies if there's another way I should be doing this.
Signed-off-by: Tony Allen <[email protected]>
Signed-off-by: Tony Allen <[email protected]>
Signed-off-by: Tony Allen <[email protected]>
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.
Thanks @tonya11en. Very excited to see this starting to land. From a quick skim looks like it's on the right track. I will review when there is 100% test coverage. Thank you!
/wait
Signed-off-by: Tony Allen <[email protected]>
@tonya11en friendly request to not force push a PR after it's open. It makes reviews much more difficult. Thank you! |
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.
Cool stuff, flushing out some comments. Note also that you are missing coverage. Please check the coverage report in CI. Thank you!
/wait
source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h
Outdated
Show resolved
Hide resolved
source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h
Outdated
Show resolved
Hide resolved
source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h
Outdated
Show resolved
Hide resolved
source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.cc
Outdated
Show resolved
Hide resolved
source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.cc
Outdated
Show resolved
Hide resolved
...extensions/filters/http/adaptive_concurrency/concurrency_controller/concurrency_controller.h
Outdated
Show resolved
Hide resolved
Signed-off-by: Tony Allen <[email protected]>
Signed-off-by: Tony Allen <[email protected]>
Signed-off-by: Tony Allen <[email protected]>
...extensions/filters/http/adaptive_concurrency/concurrency_controller/concurrency_controller.h
Outdated
Show resolved
Hide resolved
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.
Looking good! Flushing some more comments.
/wait
source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.cc
Outdated
Show resolved
Hide resolved
source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.cc
Outdated
Show resolved
Hide resolved
Signed-off-by: Tony Allen <[email protected]>
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.
Cool, thanks. A few small comments and we can ship!
/wait
source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.cc
Outdated
Show resolved
Hide resolved
source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.cc
Outdated
Show resolved
Hide resolved
source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h
Outdated
Show resolved
Hide resolved
...extensions/filters/http/adaptive_concurrency/concurrency_controller/concurrency_controller.h
Outdated
Show resolved
Hide resolved
...extensions/filters/http/adaptive_concurrency/concurrency_controller/concurrency_controller.h
Show resolved
Hide resolved
test/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter_test.cc
Outdated
Show resolved
Hide resolved
namespace HttpFilters { | ||
namespace AdaptiveConcurrency { | ||
|
||
Http::FilterFactoryCb AdaptiveConcurrencyFilterFactory::createFilterFactoryFromProtoTyped( |
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 don't think anything in this file or the NOP controller is actually used in this PR. Can we just remove it for now until we have the integration test?
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 actually forced to implement createFilterFactoryFromProtoTyped
or the filter factory is an abstract class. I ripped out everything else I could.
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.
Sorry I meant I don't think you need config.h/config.cc at all in this PR? See https://github.com/envoyproxy/envoy/blob/master/source/extensions/extensions_build_config.bzl#L79 for an example of getting tests to run w/o a config file that we don't need yet.
/wait
Signed-off-by: Tony Allen <[email protected]>
Signed-off-by: Tony Allen <[email protected]>
Signed-off-by: Tony Allen <[email protected]>
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.
LGTM, thanks. A few small nits and a question.
/wait
source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.cc
Outdated
Show resolved
Hide resolved
AdaptiveConcurrencyFilter::~AdaptiveConcurrencyFilter() = default; | ||
|
||
Http::FilterHeadersStatus AdaptiveConcurrencyFilter::decodeHeaders(Http::HeaderMap&, bool) { | ||
if (controller_->forwardingDecision() == ConcurrencyController::RequestForwardingAction::Block) { |
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.
Q: Are we eventually going to support this on a per-cluster basis? This seems probably OK for ingress, but it seems like we should support per route/cluster limiting? What is your vision there?
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 think per-cluster would make sense in the future and shouldn't be too hard to support. More thought would need to go into per-route because of runtime fractional routing.
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.
All of the interfaces will need to change if we support per-cluster, but it's OK to sort that out later.
} | ||
|
||
void AdaptiveConcurrencyFilter::encodeComplete() { | ||
const auto rq_latency = config_->timeSource().monotonicTime() - rq_start_time_; |
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.
nit: just inline this into the function call on the next line.
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 think this makes the intention more clear/readable. Similar to the 2-state enum comment from earlier.
The compiler will optimize it all to the same thing anyway.
test/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter_test.cc
Show resolved
Hide resolved
test/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter_test.cc
Outdated
Show resolved
Hide resolved
Signed-off-by: Tony Allen <[email protected]>
Signed-off-by: Tony Allen <[email protected]>
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.
Thanks!
This patch implements the adaptive concurrency controller interface and the adaptive concurrency limit filter logic #7789.
The filter's logic is quite simple. During decoding, verify if the request should bother continuing using the concurrency controller. If so, continue; otherwise, return a 503. During encoding, we will have the request's round-trip time, so this value is fed to the concurrency controller before continuing.
The concurrency controller does all of the heavy lifting in this filter. The interface can be implemented with any desired algorithm, as long as it samples request latencies, can unconditionally determine whether a request can continue on, and is thread-safe.
Assuming this patch does not dramatically change from the time the PR is opened, the next PR will be the algorithm implementation/tests.
Risk Level: No risk.
Testing: None.
Docs Changes: N/A
Initial effort towards #7789