-
Notifications
You must be signed in to change notification settings - Fork 5.4k
add rps_threshold & max_rejection_probability #16742
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b5b8523
add rps_threshold & max_rejection_probability
WeavingGao 3ee18a3
fix format
WeavingGao 543d3ab
add averageRps()
WeavingGao 80668e7
some minor changes
WeavingGao 68e3535
Modify the calculation method of avergeRps
WeavingGao 7c508c1
add some feature description
WeavingGao 0cd8d14
Merge remote-tracking branch 'upstream/main' into admission_control
WeavingGao 363a387
fix format
WeavingGao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
11 changes: 10 additions & 1 deletion
11
...pi_shadow/envoy/extensions/filters/http/admission_control/v3alpha/admission_control.proto
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -30,6 +30,8 @@ using GrpcStatus = Grpc::Status::GrpcStatus; | |
|
|
||
| static constexpr double defaultAggression = 1.0; | ||
| static constexpr double defaultSuccessRateThreshold = 95.0; | ||
| static constexpr uint32_t defaultRpsThreshold = 0; | ||
| static constexpr double defaultMaxRejectionProbability = 80.0; | ||
|
|
||
| AdmissionControlFilterConfig::AdmissionControlFilterConfig( | ||
| const AdmissionControlProto& proto_config, Runtime::Loader& runtime, | ||
|
|
@@ -44,6 +46,13 @@ AdmissionControlFilterConfig::AdmissionControlFilterConfig( | |
| sr_threshold_(proto_config.has_sr_threshold() ? std::make_unique<Runtime::Percentage>( | ||
| proto_config.sr_threshold(), runtime) | ||
| : nullptr), | ||
| rps_threshold_(proto_config.has_rps_threshold() | ||
| ? std::make_unique<Runtime::UInt32>(proto_config.rps_threshold(), runtime) | ||
| : nullptr), | ||
| max_rejection_probability_(proto_config.has_max_rejection_probability() | ||
| ? std::make_unique<Runtime::Percentage>( | ||
| proto_config.max_rejection_probability(), runtime) | ||
| : nullptr), | ||
| response_evaluator_(std::move(response_evaluator)) {} | ||
|
|
||
| double AdmissionControlFilterConfig::aggression() const { | ||
|
|
@@ -55,6 +64,16 @@ double AdmissionControlFilterConfig::successRateThreshold() const { | |
| return std::min<double>(pct, 100.0) / 100.0; | ||
| } | ||
|
|
||
| uint32_t AdmissionControlFilterConfig::rpsThreshold() const { | ||
| return rps_threshold_ ? rps_threshold_->value() : defaultRpsThreshold; | ||
| } | ||
|
|
||
| double AdmissionControlFilterConfig::maxRejectionProbability() const { | ||
| const double ret = max_rejection_probability_ ? max_rejection_probability_->value() | ||
| : defaultMaxRejectionProbability; | ||
| return ret / 100.0; | ||
| } | ||
|
|
||
| AdmissionControlFilter::AdmissionControlFilter(AdmissionControlFilterConfigSharedPtr config, | ||
| const std::string& stats_prefix) | ||
| : config_(std::move(config)), stats_(generateStats(config_->scope(), stats_prefix)), | ||
|
|
@@ -67,6 +86,11 @@ Http::FilterHeadersStatus AdmissionControlFilter::decodeHeaders(Http::RequestHea | |
| return Http::FilterHeadersStatus::Continue; | ||
| } | ||
|
|
||
| if (config_->getController().averageRps() < config_->rpsThreshold()) { | ||
| ENVOY_LOG(debug, "Current rps: {} is below rps_threshold: {}, continue"); | ||
| return Http::FilterHeadersStatus::Continue; | ||
|
Member
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. Consider throwing a debug log in here. |
||
| } | ||
|
|
||
| if (shouldRejectRequest()) { | ||
| // We do not want to sample requests that we are rejecting, since this taints the measurements | ||
| // that should be describing the upstreams. In addition, if we were to record the requests | ||
|
|
@@ -147,6 +171,7 @@ bool AdmissionControlFilter::shouldRejectRequest() const { | |
| if (aggression != 1.0) { | ||
| probability = std::pow(probability, 1.0 / aggression); | ||
| } | ||
| probability = std::min<double>(probability, config_->maxRejectionProbability()); | ||
|
|
||
| // Choosing an accuracy of 4 significant figures for the probability. | ||
| static constexpr uint64_t accuracy = 1e4; | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If this is true and these values are clamped, can you make this more clear in the API docs? If it's not true can you make it more clear here?
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 isn't true all the time-- it's just explaining how to read the configuration above. Github cut out this line just above the additions:
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.
Ah OK sorry, I missed that, thanks.