-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multitenant: implement a fallback rate
This change implements a fallback throttling rate that a SQL pod can use if it stops being able to complete token bucket requests. The goal is keep tenants without burst RUs throttled and tenants with lots of RUs unthrottled (or throttled at a high rate). To achieve this, we calculate a rate at which the tenant would burn through all their available RUs within 1 hour. The premise here is that if we have some kind of infrastructure problem, 1 hour is a reasonable time frame to address it. Beyond 1 hour, the tenant will continue at the same rate, consuming more RUs than they had available. Informs #68479. Release note: None Release justification: Necessary fix for the distributed rate limiting functionality, which is vital for the upcoming Serverless MVP release. It allows CRDB to throttle clusters that have run out of free or paid request units (which measure CPU and I/O usage). This functionality is only enabled in multi-tenant scenarios and should have no impact on our dedicated customers.
- Loading branch information
1 parent
271630c
commit 56f94dd
Showing
15 changed files
with
882 additions
and
627 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Tests in this file verify the enacting of the fallback rate when token bucket | ||
# requests are erroring out. | ||
|
||
configure | ||
fallback_rate: 1000 | ||
---- | ||
|
||
# Issue a large request, forcing fetching of more RUs. | ||
write bytes=50000000 | ||
---- | ||
|
||
configure | ||
error: true | ||
---- | ||
|
||
advance | ||
1s | ||
---- | ||
00:00:01.000 | ||
|
||
# Issue a large request that requires more RUs. | ||
write bytes=100000000 label=w1 | ||
---- | ||
|
||
# Wait until we process the "low RU" notification (where we set the fallback rate | ||
# start time). | ||
wait-for-event | ||
low-ru | ||
---- | ||
|
||
advance | ||
5s | ||
---- | ||
00:00:06.000 | ||
|
||
# The fallback rate should kick in when we process a tick at the current time. | ||
wait-for-event | ||
tick | ||
---- | ||
|
||
advance | ||
10s | ||
---- | ||
00:00:16.000 | ||
|
||
not-completed label=w1 | ||
---- | ||
|
||
advance | ||
30s | ||
---- | ||
00:00:46.000 | ||
|
||
await label=w1 | ||
---- |
67 changes: 67 additions & 0 deletions
67
pkg/ccl/multitenantccl/tenantcostclient/testdata/fallback-throttled
This file contains 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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Tests in this file verify the enacting of the fallback rate when token bucket | ||
# requests start erroring out while we are being throttled. | ||
|
||
wait-for-event | ||
token-bucket-response | ||
---- | ||
|
||
configure | ||
throttle: 100 | ||
fallback_rate: 1000 | ||
---- | ||
|
||
# Large request that requires more than the initial RUs. | ||
write bytes=100000000 label=w2 | ||
---- | ||
|
||
wait-for-event | ||
low-ru | ||
---- | ||
|
||
wait-for-event | ||
token-bucket-response | ||
---- | ||
|
||
# We were granted 10s worth of tokens at 100 RU/s. | ||
timers | ||
---- | ||
00:00:09.000 | ||
00:04:41.479 | ||
|
||
|
||
configure | ||
error: true | ||
---- | ||
|
||
advance | ||
10s | ||
---- | ||
00:00:10.000 | ||
|
||
# Wait until we process the "low RU" notification (where we set the fallback rate | ||
# start time). | ||
wait-for-event | ||
low-ru | ||
---- | ||
|
||
advance | ||
2s | ||
---- | ||
00:00:12.000 | ||
|
||
# We would set up the fallback rate now, which should allow the request to go | ||
# through much sooner than 4 minutes. | ||
wait-for-event | ||
tick | ||
---- | ||
|
||
not-completed label=w2 | ||
---- | ||
|
||
advance | ||
30s | ||
---- | ||
00:00:42.000 | ||
|
||
await label=w2 | ||
---- |
This file contains 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 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 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.