-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
71149: tenantcostclient: smooth over debt payback r=RaduBerinde a=RaduBerinde Prior to this commit, the tenant's local token bucket stalls all traffic whenever it incurs debt. This is a problem because some debt comes in discrete "packets" (CPU usage is accounted for once a second), which can lead to large occasional latency spikes. This change improves the debt repayment mechanism: instead of paying the debt as soon as possible, we aim to pay the debt within 2 seconds of when the debt is incurred and earmark part of the rate for debt repayment; the remaining rate can be used by requests in the mean time. The comment in `token_bucket.go` goes over more details. 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. ### Plots for latency data from the debt test Before: ![image](https://user-images.githubusercontent.com/16544120/136071271-fee831e8-593a-4d82-b7f7-4ac30c0e3e1c.png) After: ![image](https://user-images.githubusercontent.com/16544120/136071244-a86afbc5-55f8-4c26-b578-bc3e31538ffd.png) Co-authored-by: Radu Berinde <[email protected]>
- Loading branch information
Showing
5 changed files
with
385 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
wait-for-event | ||
token-bucket-response | ||
---- | ||
|
||
# Set up throttling at 1000 RU/s. | ||
configure | ||
throttle: 1000 | ||
---- | ||
|
||
# Fire off a write that needs more than the 10000 initial RUs. | ||
write bytes=6000000 label=w1 | ||
---- | ||
|
||
wait-for-event | ||
token-bucket-response | ||
---- | ||
|
||
timers | ||
---- | ||
00:00:01.600 | ||
00:00:09.000 | ||
|
||
advance | ||
2s | ||
---- | ||
00:00:02.000 | ||
|
||
wait-for-event | ||
tick | ||
---- | ||
|
||
await label=w1 | ||
---- | ||
|
||
# Do a read which incurs a debt of about 1000 RUs upon completion. | ||
read bytes=10000000 | ||
---- | ||
|
||
# Verify that a small write doesn't have to wait a second for the entire debt | ||
# to be paid. | ||
write bytes=1024 label=w2 | ||
---- | ||
|
||
timers | ||
---- | ||
00:00:02.011 | ||
00:00:09.000 | ||
|
||
advance | ||
100ms | ||
---- | ||
00:00:02.100 | ||
|
||
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
Oops, something went wrong.