Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kv: split rate limits and metrics for read and write requests #53510

Merged

Conversation

nvanbenschoten
Copy link
Member

@nvanbenschoten nvanbenschoten commented Aug 26, 2020

Fixes #53483.

This commit splits the existing request rate limit into two categories, read requests and write requests. Experimentation has shown that the fixed cost of a request is dramatically different between these two categories, primarily because write requests need to go through Raft while read requests do not. By splitting the limits and metrics along this dimension, we expect to be able to more accurately model the cost of KV traffic and more effectively tune rate limits.

In making the split, the commit replaces the existing metric:

kv.tenant_rate_limit.requests_admitted

with the following two new metrics:

kv.tenant_rate_limit.read_requests_admitted
kv.tenant_rate_limit.write_requests_admitted

The commit also replaced the existing two settings:

kv.tenant_rate_limiter.requests.rate_limit
kv.tenant_rate_limiter.request.burst_limit

with the following four new settings:

kv.tenant_rate_limiter.read_requests.rate_limit
kv.tenant_rate_limiter.read_requests.burst_limit
kv.tenant_rate_limiter.write_requests.rate_limit
kv.tenant_rate_limiter.write_requests.burst_limit

Release justification: Low-risk, high benefit change.

This makes the code cleaner and avoids the `ba.IsWrite()` call for
read-only requests.
@nvanbenschoten nvanbenschoten added the A-multitenancy Related to multi-tenancy label Aug 26, 2020
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/readWriteRequests branch from 434d6de to 3bcec6c Compare August 26, 2020 21:29
This commit splits the existing request rate limit into two categories,
read requests and write requests. Experimentation has shown that the
fixed cost of a request is dramatically different between these two
categories, primarily because write requests need to go through Raft
while read requests do not. By splitting the limits and metrics
along this dimension, we expect to be able to more accurately model
the cost of KV traffic and more effectively tune rate limits.

In making the split, the commit replaces the existing metric:
```
kv.tenant_rate_limit.requests_admitted
```
with the following two new metrics:
```
kv.tenant_rate_limit.read_requests_admitted
kv.tenant_rate_limit.write_requests_admitted
```

The commit also replaced the existing two settings:
```
kv.tenant_rate_limiter.requests.rate_limit
kv.tenant_rate_limiter.request.burst_limit
```
with the following four new settings:
```
kv.tenant_rate_limiter.read_requests.rate_limit
kv.tenant_rate_limiter.read_requests.burst_limit
kv.tenant_rate_limiter.write_requests.rate_limit
kv.tenant_rate_limiter.write_requests.burst_limit
```

Release justification: Low-risk, high benefit change.
@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/readWriteRequests branch from 3bcec6c to 4c9110f Compare August 26, 2020 21:54
Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r1, 15 of 15 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

@nvanbenschoten
Copy link
Member Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 27, 2020

Build failed:

@nvanbenschoten
Copy link
Member Author

PR description was missing release justification.

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 27, 2020

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Aug 27, 2020

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Aug 27, 2020

This PR was included in a batch that was canceled, it will be automatically retried

@craig
Copy link
Contributor

craig bot commented Aug 27, 2020

Build succeeded:

@craig craig bot merged commit e43acc9 into cockroachdb:master Aug 27, 2020
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/readWriteRequests branch August 29, 2020 21:19
ajwerner added a commit to ajwerner/cockroach that referenced this pull request Aug 31, 2020
This test was broken in cockroachdb#53510 which augmented the limiter machinery to
deal with read and write requests independently. The problem is that the
timer machinery works to synchronize the first blocked request but not
subsequent requests. That leaves the test-writer with no fundamental
means to ensure that subsequent blocked commands synchronize with a
metrics command. This lack of synchronization on metrics was a pain-point
when writing the original tests and led to excessive use of timers as
synchronization. Rather than trying to add excess synchronization, this
commit just adds a succeeds soon around the metrics. This works well.

Fixes cockroachdb#53590

Release justification: non-production code changes

Release note: None
craig bot pushed a commit that referenced this pull request Aug 31, 2020
53661: kvserver/tenantrate: fix flakey test r=nvanbenschoten a=ajwerner

This test was broken in #53510 which augmented the limiter machinery to
deal with read and write requests independently. The problem is that the
timer machinery works to synchronize the first blocked request but not
subsequent requests. That leaves the test-writer with no fundamental
means to ensure that subsequent blocked commands synchronize with a
metrics command. This lack of synchronization on metrics was a pain-point
when writing the original tests and led to excessive use of timers as
synchronization. Rather than trying to add excess synchronization, this
commit just adds a succeeds soon around the metrics. This works well.

Fixes #53590

Release justification: non-production code changes

Release note: None

Co-authored-by: Andrew Werner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-multitenancy Related to multi-tenancy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kv: split read and write request rate limiters
3 participants