Skip to content

Commit db59df1

Browse files
committed
RFC: add rfc for quota limiters.
Signed-off-by: BornChanger <[email protected]>
1 parent 8ff7a8e commit db59df1

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

text/0089-quota-limiter.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Quota limiter
2+
3+
- RFC PR: [https://github.com/tikv/rfcs/pull/89](https://github.com/tikv/rfcs/pull/89)
4+
- Tracking Issue: [https://github.com/tikv/tikv/issues/12131](https://github.com/tikv/tikv/issues/12131)
5+
[https://github.com/tikv/tikv/issues/12503](https://github.com/tikv/tikv/issues/12503)
6+
7+
## Summary
8+
9+
Add a global throttle to limit read/write requests, which brings stable QPS.
10+
11+
## Motivation
12+
13+
On the machines where physical resources are constrained, the performance of TiKV may become unstable. Front-end and back-end processing interfere with each other. For example, TiKV's processing of background sampling will take up a lot of CPU processing time, which will cause other requests to be processed with less cpu resource. In addition, under long-term high load pressure, TiKV will accumulate more and more background tasks, such as compaction jobs, etc. When resources are limited and users are not sensitive to performance, it's better for TiKV to work stably under high pressure.
14+
15+
## Detailed design
16+
17+
### Limited method
18+
19+
This feature plans to add multiple global limiters into TiKV to record different types of processing speed. These types include CPU time, read/write bandwidth.
20+
21+
When the limiter reaches the quota value, the request will be forced to block for a period of time to compensate, based on the result returned from a speed limiter using the token bucket algorithm.
22+
23+
Several new configs will be added. Users need to limit each metric separately, of which the quota for cpu time is an approximate value.
24+
25+
* quota.foreground-cpu-time: usize
26+
* quota.foreground-write-bandwidth: ReadableSize
27+
* quota.foreground-read-bandwidth: ReadableSize
28+
* quota.background-cpu-time: usize
29+
* quota.background-write-bandwidth: ReadableSize
30+
* quota.background-read-bandwidth: ReadableSize
31+
* quota.max-delay-duration: ReadableDuration
32+
* quota.enable-auto-tune: bool
33+
34+
We separate the quota configuration of foreground and background requests. `max-delay-duration` is used to specify the ceiling of penalty.
35+
And if `quota.enable-auto-tune` is on, quota can be adjusted according runtime workload of the TiKV instance.
36+
37+
### Limited position
38+
39+
Clock and limit at the location of code blocks for the above metric that will significantly affect.
40+
41+
**scheduler write:** All txn write requests will be handled in the `process_write` function.
42+
43+
**tidb query executor:** Coprocessor DAG processing will be handled in `BatchExecutorsRunner`.
44+
45+
**txn get:** Get value processing will be handled in `storage::get`
46+
47+
**txn batch get:** Get multiple value processing will be handled in `storage::batch_get`
48+
49+
**analyze request:** Coprocessor analyze processing will be handled in `collect_columns_stats`.
50+
51+
## Drawbacks
52+
53+
Setting a quota that is too small may cause significant performance degradation, which requires experienced users to config the quota.

0 commit comments

Comments
 (0)