-
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.
tenantcostclient: smooth over debt payback
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.
- Loading branch information
1 parent
d6a53cb
commit e3417f2
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.