// Module included in the following assemblies:
//
// assembly-config.adoc

[id='proc-setting-broker-limits-{context}']

= Setting throughput and storage limits on brokers

[role="_abstract"]
This procedure describes how to set throughput and storage limits on brokers in your Kafka cluster.
Enable a quota plugin and configure limits using `quotas` properties in the `Kafka` resource.

.Quota plugins

There are two types of quota plugins available:

* The `strimzi` type enables the _Strimzi Quotas_ plugin.
* The `kafka` type enables the built-in Kafka plugin. 

Only one quota plugin can be enabled at a time. 
The built-in `kafka` plugin is enabled by default.
Enabling the `strimzi` plugin automatically disables the built-in plugin.

.`strimzi` plugin

The `strimzi` plugin provides storage utilization quotas and dynamic distribution of throughput limits.

* Storage quotas throttle Kafka producers based on disk storage utilization. 
Limits can be specified in bytes (`minAvailableBytesPerVolume`) or percentage (`minAvailableRatioPerVolume`) of available disk space, applying to each disk individually. 
When any broker in the cluster exceeds the configured disk threshold, clients are throttled to prevent disks from filling up too quickly and exceeding capacity.
* A total throughput limit is distributed dynamically across all clients.
For example, if you set a 40 MBps producer byte-rate threshold, the distribution across two producers is not static. 
If one producer is using 10 MBps, the other can use up to 30 MBps.
* Specific users (clients) can be excluded from the restrictions.

NOTE: With the `strimzi` plugin, you see only aggregated quota metrics, not per-client metrics.

.`kafka` plugin

The `kafka` plugin applies throughput limits on a per-user, per-broker basis and includes additional CPU and operation rate limits.

* Limits are applied per user and per broker. 
For example, setting a 20 MBps producer byte-rate threshold limits each user to 20 MBps on a per-broker basis across all producer connections for that user. 
There is no total throughput limit as there is in the `strimzi` plugin.
Limits can be overridden by xref:con-configuring-client-quotas-str[user-specific quota configurations].
* CPU utilization limits for each client can be set as a percentage of the network threads and I/O threads on a per-broker basis.
* The number of concurrent partition creation and deletion operations (mutations) allowed per second can be set on a per-broker basis.

.Prerequisites

* The Cluster Operator that manages the Kafka cluster is running.

.Procedure

. Add the plugin configuration to the `quotas` section of the `Kafka` resource.
+
--
.Example `strimzi` plugin configuration
[source,yaml,subs="+attributes"]
----
apiVersion: {KafkaApiVersion}
kind: Kafka
metadata:
  name: my-cluster
spec:
  kafka:
    # ...
    quotas:
      type: strimzi
      producerByteRate: 1000000 # <1>
      consumerByteRate: 1000000 # <2>
      minAvailableBytesPerVolume: 500000000000 # <3>
      excludedPrincipals: # <4>
        - my-user
----
<1> Sets a producer byte-rate threshold of 1 MBps.
<2> Sets a consumer byte-rate threshold of 1 MBps.
<3> Sets an available bytes limit for storage of 500 GB.
<4> Excludes `my-user` from the restrictions.

`minAvailableBytesPerVolume` and `minAvailableRatioPerVolume` are mutually exclusive.
Only configure one of these parameters.
--
+
.Example `kafka` plugin configuration
[source,yaml,subs="+attributes"]
----
apiVersion: {KafkaApiVersion}
kind: Kafka
metadata:
  name: my-cluster
spec:
  kafka:
    # ...
    quotas:
      type: kafka
      producerByteRate: 1000000
      consumerByteRate: 1000000
      requestPercentage: 55 # <1>
      controllerMutationRate: 50 # <2>
----
<1> Sets the CPU utilization limit to 55%.
<2> Sets the controller mutation rate to 50 operations per second.

. Apply the changes to the `Kafka` configuration.

NOTE: `minAvailableBytesPerVolume` and `minAvailableRatioPerVolume` are mutually exclusive.
This means that only one of these parameters should be configured.

NOTE: Additional options can be configured in the `spec.kafka.config` section.
The full list of supported options can be found in the https://github.com/strimzi/kafka-quotas-plugin?tab=readme-ov-file#properties-and-their-defaults[plugin documentation].

[role="_additional-resources"]
.Additional resources

* link:{BookURLConfiguring}#type-QuotasPluginStrimzi-reference[`QuotasPluginStrimzi` schema reference^]
* link:{BookURLConfiguring}#type-QuotasPluginKafka-reference[`QuotasPluginKafka` schema reference^]
