envoy icon indicating copy to clipboard operation
envoy copied to clipboard

Admission Control: QPS threshold

Open WeavingGao opened this issue 5 years ago • 6 comments

Title: A threshold of queries per second that triggers throttling strategy

Description:

The admission control filter rejects requests based on the success rate of previous requests. However, in a low QPS scenario, a small number of request failures will make the request success rate very low, which will trigger the rejection behavior, thereby further reducing the failure rate of subsequent requests. To make matters worse, the filter has a per-worker time window, which means that the QPS carried by each worker is lower. In fact, in a low QPS scenario, admission control is unnecessary. We can add a QPS threshold configuration and only when the QPS exceeds this threshold, the filter will calculate the failure rate and perform subsequent actions.

cc @tonya11en @mattklein123

WeavingGao avatar May 08 '21 07:05 WeavingGao

This makes perfect sense and is totally necessary. Other implementations of this mechanism I've seen in the wild at scale have this minimum RPS threshold.

This would be super easy to implement. We already track the number of request at 1 second granularity, so we can just have a simple conditional that checks the most recent second for some minimum number of requests before rejecting. It should be one of the values at the back of the deque.

I'd be happy to review a PR if you (or any other reader) feel comfortable submitting one or point folks to the exact line this would be if needed. Otherwise, I can get to this when I have the cycles. There are some other items I'd want to get to beforehand.

tonya11en avatar May 08 '21 08:05 tonya11en

While we're at it, some other low-hanging-fruit here would be to also add a maximum throttling percentage and default to some sane value like 80%.

tonya11en avatar May 08 '21 08:05 tonya11en

I'll submit a PR.

WeavingGao avatar May 08 '21 09:05 WeavingGao

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 09 '21 20:06 github-actions[bot]

This is still in review.

tonya11en avatar Jun 09 '21 20:06 tonya11en

Merged in #16742.

WeavingGao avatar Jun 11 '21 03:06 WeavingGao