On this page
Kafka Improvement Proposal
KIP-13: client quotas, throttle instead of fail
KIP-13 added quotas to Kafka: a cap on how many bytes per second a client, or a user, can produce or fetch from each broker. A client over its quota is not rejected; the broker delays its response so its average rate drops back under the limit. Later KIPs added a quota on request time and an admin API to manage quotas.
- Proposal
- KIP-13, Quotas
- Status
- Shipped Since Kafka 0.9 (2015); throttling reworked in 2.0 (KIP-219), admin API in 2.6 (KIP-546).
- Area
- Cluster and operations
- Proposal page
- KIP-13 on the Apache Kafka wiki
Why it was needed
Without quotas one runaway producer or a consumer replaying a whole topic could use all of a broker's network and disk, and every other client on the cluster would slow down with it. In a shared, multi-tenant cluster there was no way to protect teams from each other.
What it changes
Quotas are set per user, per client id or both, and apply per broker: producer_byte_rate, consumer_byte_rate and request_percentage, the share of broker thread time. The broker measures rates over short windows. Since KIP-219 (Kafka 2.0) it answers at once with the throttle time and then mutes the connection for that long, and the client also holds back, so a throttled client sees higher latency, never an error.
How to use it
- Set quotas with kafka-configs.sh --alter --entity-type users or clients --add-config producer_byte_rate=1048576, or through the Admin API (KIP-546).
- Use --entity-default for a default per user or client; the static quota.producer.default settings were removed in Kafka 3.0.
Where it stands
Shipped in Kafka 0.9 and extended since: request-time quotas in 0.11, the throttling rework of KIP-219 in 2.0, and the describeClientQuotas and alterClientQuotas admin calls of KIP-546 in 2.6. Quotas work the same on KRaft clusters.
What comes next
Stable. Kafka 4.4 deprecated one method of the pluggable quota callback, to be removed in 5.0. Replication has its own, separate throttle (KIP-73).
See it in the simulator
- producer_byte_rate: how a Kafka client quota throttles (Quotas: throttling a producer) Step 3: Over budget - throttled 1000 ms Open at this step: producer_byte_rate: how a Kafka client quota throttles
- producer_byte_rate: how a Kafka client quota throttles (Quotas: throttling a producer) Step 5: Recovered - rate held to quota Open at this step: producer_byte_rate: how a Kafka client quota throttles
Sources
- KIP-13: Quotas
- KIP-219: Improve quota communication
- KIP-546: Add Client Quota APIs to the Admin Client
- Apache Kafka 4.4: basic operations (quotas)