Skip to content

Commit

Permalink
k/quotas: disable produce quota by default
Browse files Browse the repository at this point in the history
* Reinterpret the 0 value of `target_quota_byte_rate` as disable (this
  is safe as previously the minimum value was 1MB, so noone has this set
  to 0)
* Change the default value to be disabled
  • Loading branch information
pgellert committed Jun 27, 2024
1 parent 7b81aa8 commit 6c3a86b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/v/config/configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,13 @@ configuration::configuration()
, target_quota_byte_rate(
*this,
"target_quota_byte_rate",
"Target request size quota byte rate (bytes per second) - 2GB default",
"Target request size quota byte rate (bytes per second) - disabled "
"default (= 0)",
{.needs_restart = needs_restart::no,
.example = "1073741824",
.visibility = visibility::user},
2_GiB,
{.min = 1_MiB})
target_produce_quota_byte_rate_default,
{.min = 0})
, target_fetch_quota_byte_rate(
*this,
"target_fetch_quota_byte_rate",
Expand Down
3 changes: 3 additions & 0 deletions src/v/config/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ namespace config {
/// can not depend on any other module to prevent cyclic dependencies.

struct configuration final : public config_store {
constexpr static auto target_produce_quota_byte_rate_default
= 0; // disabled

// WAL
bounded_property<uint64_t> log_segment_size;
property<std::optional<uint64_t>> log_segment_size_min;
Expand Down
9 changes: 7 additions & 2 deletions src/v/kafka/server/client_quota_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <seastar/util/variant_utils.hh>

#include <optional>

namespace kafka {

using cluster::client_quota::entity_key;
Expand Down Expand Up @@ -274,8 +276,11 @@ client_quota_translator::get_quota_config(client_quota_type qt) const {
std::optional<uint64_t>
client_quota_translator::get_default_config(client_quota_type qt) const {
switch (qt) {
case kafka::client_quota_type::produce_quota:
return _default_target_produce_tp_rate();
case kafka::client_quota_type::produce_quota: {
auto produce_quota = _default_target_produce_tp_rate();
return (produce_quota > 0) ? std::make_optional<uint64_t>(produce_quota)
: std::nullopt;
}
case kafka::client_quota_type::fetch_quota:
return _default_target_fetch_tp_rate();
case kafka::client_quota_type::partition_mutation_quota:
Expand Down
2 changes: 1 addition & 1 deletion src/v/kafka/server/tests/client_quota_translator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ SEASTAR_THREAD_TEST_CASE(quota_translator_default_test) {
fixture f;

auto default_limits = client_quota_limits{
.produce_limit = scale_to_smp_count(2147483648),
.produce_limit = std::nullopt,
.fetch_limit = std::nullopt,
.partition_mutation_limit = std::nullopt,
};
Expand Down

0 comments on commit 6c3a86b

Please sign in to comment.