-
Notifications
You must be signed in to change notification settings - Fork 552
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
Throttle fetch requests on response size quota #7658
Conversation
441e2e2
to
a4bb7e3
Compare
476d57f
to
2ac5095
Compare
@@ -29,6 +29,7 @@ | |||
#include <absl/container/flat_hash_map.h> | |||
|
|||
#include <memory> | |||
#include <string_view> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string_view
is not used in this header
@@ -302,6 +309,7 @@ class connection_context final | |||
const bool _enable_authorizer; | |||
ctx_log _authlog; | |||
std::optional<security::tls::mtls_state> _mtls_state; | |||
request_data _request_data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(discuss) Can it be a better idea to save this data in session_resources
instead? As far as I understand, session_resources
is an object that is local to handling of a request, and is strogly associated with it. Whereas connection_context
is a long living one with lifetime same as connection's, and shared between all the requests from that connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
"target_fetch_quota_byte_rate", | ||
"Target fetch size quota byte rate (bytes per second) - disabled default", | ||
{.needs_restart = needs_restart::no, .visibility = visibility::user}, | ||
std::nullopt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(discuss) I think there is some value in making the response TP rate limiting symmetric to request TP limiting. Request TP limit default is 2GB/s, and when it was introduced it was not 100% compatible to what had been before. However the 2GB/s is quite a huge limit and I don't think that many of our customers can ever face it. Please let me know if you think there are any pros for making it different in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we can make this disabled by default to save previous behavior.
It is hard to understand how much customers really consume. Maybe somebody have multiple consumers with same client_id
If customer wants this limit, he can configure it
src/v/kafka/server/quota_manager.cc
Outdated
rate, | ||
*_target_fetch_tp_rate(), | ||
it->second.tp_fetch_rate.window_size()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to supply rate_tracker&
and uint32_t target_fetch_rate
as arguments to quota_manager::throttle()
. Then enum request_type
won't be needed and the code will be saved from extra branching and from the code duplication above.
consumer.poll(timeout_ms=1000, max_records=1) | ||
assert consumer.metrics( | ||
)["consumer-fetch-manager-metrics"]["fetch-throttle-time-max"] > 0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides just the fact that throttling occurs, it would be great to verify that the actual configured limit is honoured. For example, consume 100MB at 10MB/s rate and make sure that it does not happen faster than in 10s.
57f720f
to
69b2849
Compare
700eec8
to
eb37c79
Compare
Question - per session (tcp) couldn’t the source core keep a float32 of a rate of bytes of fetches and predictively slow down the fetch request size by mutating the request object itself for some time period like say every 3 seconds it resets if no fetch is received |
Do you mean something like predict next fetch size according to previous results? |
eb37c79
to
e1b2e10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
== fetch_api::key) { | ||
_server.quota_mgr().record_fetch_tp( | ||
resp_and_res.resources->request_data.client_id, msg.size()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think the try...catch here is only intended to mask exceptions thrown in conn->write()
, so I would rather place this call before try
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/ci-repeat 10 |
e1b2e10
to
bcad727
Compare
/ci-repeat 10 |
bcad727
to
43da9b3
Compare
/ci-repeat 10 |
/ci-repeat 10 |
bbb0f75
to
0d2c37c
Compare
/ci-repeat 10 |
0d2c37c
to
fbf9f06
Compare
/ci-repeat 10 |
Not apply request throttling to fetch requests. Fetch request now throttled by response size. If fetch request break quota limit next request will be throttled according to previous rate.
fbf9f06
to
7bbbc63
Compare
/ci-repeat 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this going to have conflicts with @dlex 's PR that adds new control at the kakfa layer? we should make sure the sequence of merging makes sense.
np, I will resolve them |
Don't use request throttling to fetch requests.
Fetch requests are small, so we don't need to throttle it on requests size.
We need to throttle fetch requests on response size.
This pr creates separate quota for response sizes. This quota is used for fetch requests.
We cannot calculate response size before we calculate response. So we can get current response size rate only when we have already evaluated response.
Delaying response when we have already done all calculation has no sense. So we write response size to quota manager and use this history to delay next fetch request that will come to node.
Backports Required
Release Notes
Features
target_fetch_quota_byte_rate
- target fetch size quota byte rate for client (bytes per second). Disabled by default