Skip to content
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

Merged
merged 17 commits into from
Aug 8, 2019

Conversation

tonya11en
Copy link
Member

@tonya11en tonya11en commented Aug 3, 2019

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

Tony Allen and others added 4 commits August 2, 2019 16:14
Signed-off-by: Tony Allen <tallen@lyft.com>
Signed-off-by: Tony Allen <tony@allen.gg>
Signed-off-by: Tony Allen <tony@allen.gg>
Signed-off-by: Tony Allen <tony@allen.gg>
Copy link
Member Author

@tonya11en tonya11en left a 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.

CODEOWNERS Show resolved Hide resolved
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7819 was synchronize by tonya11en.

see: more, trace.

Signed-off-by: Tony Allen <tony@allen.gg>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7819 was synchronize by tonya11en.

see: more, trace.

@tonya11en tonya11en marked this pull request as ready for review August 3, 2019 00:25
Signed-off-by: Tony Allen <tony@allen.gg>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7819 was synchronize by tonya11en.

see: more, trace.

Signed-off-by: Tony Allen <tony@allen.gg>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7819 was synchronize by tonya11en.

see: more, trace.

@mattklein123 mattklein123 self-assigned this Aug 3, 2019
Copy link
Member

@mattklein123 mattklein123 left a 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

@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7819 was synchronize by tonya11en.

see: more, trace.

Signed-off-by: Tony Allen <tony@allen.gg>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7819 was synchronize by tonya11en.

see: more, trace.

@mattklein123
Copy link
Member

@tonya11en friendly request to not force push a PR after it's open. It makes reviews much more difficult. Thank you!

Copy link
Member

@mattklein123 mattklein123 left a 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

Tony Allen added 3 commits August 5, 2019 16:06
Signed-off-by: Tony Allen <tallen@lyft.com>
Signed-off-by: Tony Allen <tallen@lyft.com>
Signed-off-by: Tony Allen <tallen@lyft.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7819 was synchronize by tonya11en.

see: more, trace.

Copy link
Member

@mattklein123 mattklein123 left a 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

Signed-off-by: Tony Allen <tallen@lyft.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7819 was synchronize by tonya11en.

see: more, trace.

Copy link
Member

@mattklein123 mattklein123 left a 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

namespace HttpFilters {
namespace AdaptiveConcurrency {

Http::FilterFactoryCb AdaptiveConcurrencyFilterFactory::createFilterFactoryFromProtoTyped(
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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 <tallen@lyft.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7819 was synchronize by tonya11en.

see: more, trace.

Signed-off-by: Tony Allen <tallen@lyft.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7819 was synchronize by tonya11en.

see: more, trace.

Signed-off-by: Tony Allen <tallen@lyft.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7819 was synchronize by tonya11en.

see: more, trace.

Copy link
Member

@mattklein123 mattklein123 left a 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

AdaptiveConcurrencyFilter::~AdaptiveConcurrencyFilter() = default;

Http::FilterHeadersStatus AdaptiveConcurrencyFilter::decodeHeaders(Http::HeaderMap&, bool) {
if (controller_->forwardingDecision() == ConcurrencyController::RequestForwardingAction::Block) {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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_;
Copy link
Member

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.

Copy link
Member Author

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.

Tony Allen added 2 commits August 7, 2019 15:28
Signed-off-by: Tony Allen <tallen@lyft.com>
Signed-off-by: Tony Allen <tallen@lyft.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7819 was synchronize by tonya11en.

see: more, trace.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mattklein123 mattklein123 merged commit 8e1dd33 into envoyproxy:master Aug 8, 2019
@tonya11en tonya11en deleted the acc_filter branch September 25, 2019 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants