Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

Kafka Quotas Configuration

Quotas limit resource consumption by Kafka clients. They prevent individual clients from monopolizing cluster resources and enable fair resource sharing across applications.


Quota TypeMetricUnitPurpose
producer_byte_rateProducer throughputbytes/secLimit write bandwidth
consumer_byte_rateConsumer throughputbytes/secLimit read bandwidth
request_percentageRequest handler time% of capacityLimit CPU usage
controller_mutation_rateMetadata mutationsmutations/secLimit control plane load

Quotas can be applied to different entity combinations:

Quota entity precedence from user and client ID to cluster defaultQuota entity precedence from user and client ID to cluster defaultQuota Hierarchy (Most Specific Wins)User + Client ID(Highest Priority)User OnlyClient ID OnlyDefault UserDefault Client IDCluster Default(Lowest Priority)fallbackfallbackfallbackfallbackfallbackfallback
EntityDescriptionExample
UserAuthenticated principalUser:alice
Client IDClient identifier stringproducer-app-1
User + Client IDSpecific user with specific clientUser:alice + producer-1
DefaultApplies to all users/clients<default>

Terminal window
# Quota for specific user
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'producer_byte_rate=10485760' \
--entity-type users \
--entity-name producer-user
# Quota for specific client ID
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'producer_byte_rate=5242880' \
--entity-type clients \
--entity-name my-producer-app
# Quota for user + client ID combination
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'producer_byte_rate=20971520' \
--entity-type users \
--entity-name producer-user \
--entity-type clients \
--entity-name high-priority-producer
Terminal window
# Consumer quota for user
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'consumer_byte_rate=52428800' \
--entity-type users \
--entity-name consumer-user
# Consumer quota for client ID
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'consumer_byte_rate=26214400' \
--entity-type clients \
--entity-name my-consumer-app
Terminal window
# Limit CPU usage to 50% of one I/O thread
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'request_percentage=50' \
--entity-type users \
--entity-name batch-processor
Terminal window
# Default quota for all users
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'producer_byte_rate=10485760,consumer_byte_rate=52428800' \
--entity-type users \
--entity-default
# Default quota for all client IDs
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'producer_byte_rate=5242880' \
--entity-type clients \
--entity-default

Terminal window
# View quota for specific user
kafka-configs.sh --bootstrap-server kafka:9092 \
--describe \
--entity-type users \
--entity-name producer-user
# View quota for specific client
kafka-configs.sh --bootstrap-server kafka:9092 \
--describe \
--entity-type clients \
--entity-name my-producer-app
# View all user quotas
kafka-configs.sh --bootstrap-server kafka:9092 \
--describe \
--entity-type users
# View default quotas
kafka-configs.sh --bootstrap-server kafka:9092 \
--describe \
--entity-type users \
--entity-default

Terminal window
# Remove specific quota
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--delete-config 'producer_byte_rate' \
--entity-type users \
--entity-name producer-user
# Remove all quotas for entity
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--delete-config 'producer_byte_rate,consumer_byte_rate,request_percentage' \
--entity-type users \
--entity-name producer-user

When multiple quotas apply, the most specific quota takes precedence:

  1. User + Client ID - Most specific
  2. User only
  3. Client ID only
  4. Default User (--entity-default)
  5. Default Client ID (--entity-default)
  6. No quota - Unlimited
User: alice, Client ID: producer-1
Quota sources:
1. User:alice + Client:producer-1 → 20 MB/s (APPLIED)
2. User:alice → 10 MB/s
3. Client:producer-1 → 5 MB/s
4. Default User → 1 MB/s
5. Default Client → 1 MB/s
Result: 20 MB/s (most specific match wins)

# Broker configuration for quota enforcement
quota.window.num=11
quota.window.size.seconds=1
SettingDefaultDescription
quota.window.num11Number of samples for rate calculation
quota.window.size.seconds1Duration of each sample window
# Limit metadata mutations per second
controller.quota.window.num=11
controller.quota.window.size.seconds=1
Terminal window
# Set controller mutation quota
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'controller_mutation_rate=10' \
--entity-type users \
--entity-name admin-user

When a client exceeds its quota:

  1. Broker calculates delay based on excess usage
  2. Response includes throttle_time_ms
  3. Client pauses before next request
  4. Metrics track throttling events
Broker throttling a producer that exceeds its byte rate quotaClientBrokerClientClientBrokerBrokerProduce (100 MB in 1 sec)Check quota (50 MB/s)Calculate delay = 1 secResponse (throttle_time_ms=1000)Wait 1 secondNext Produce request
MetricDescription
produce-throttle-timeProducer throttle time (ms)
fetch-throttle-timeConsumer throttle time (ms)
request-timeTotal request time including throttle

Terminal window
# Tenant A: High priority
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'producer_byte_rate=104857600,consumer_byte_rate=209715200' \
--entity-type users \
--entity-name tenant-a
# Tenant B: Standard
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'producer_byte_rate=52428800,consumer_byte_rate=104857600' \
--entity-type users \
--entity-name tenant-b
# Tenant C: Basic
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'producer_byte_rate=10485760,consumer_byte_rate=20971520' \
--entity-type users \
--entity-name tenant-c
Terminal window
# Critical applications - high quota
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'producer_byte_rate=104857600' \
--entity-type clients \
--entity-name 'critical-*'
# Batch jobs - limited quota
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'producer_byte_rate=10485760,request_percentage=25' \
--entity-type clients \
--entity-name 'batch-*'
# Default for unknown applications
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'producer_byte_rate=5242880,consumer_byte_rate=10485760' \
--entity-type clients \
--entity-default
Terminal window
# Limit admin operations
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'controller_mutation_rate=50' \
--entity-type users \
--entity-name admin-user
# Limit automation tools
kafka-configs.sh --bootstrap-server kafka:9092 \
--alter \
--add-config 'controller_mutation_rate=10' \
--entity-type users \
--entity-name ci-cd-user

WorkloadSuggested QuotaRationale
High-priority100 MB/sReal-time applications
Standard50 MB/sNormal production traffic
Batch10-20 MB/sBackground processing
Development5 MB/sNon-production
WorkloadSuggested QuotaRationale
High-priority200 MB/sReal-time consumers
Standard100 MB/sNormal consumption
Analytics50 MB/sBatch analytics
Monitoring10 MB/sMetrics collection
Application TypeSuggested %Rationale
Critical100%No throttling
Standard50-75%Fair share
Batch25%Background priority
Development10%Limited resources

# Per-user metrics
kafka.server:type=Fetch,user=([-.\w]+),client-id=([-.\w]+)
kafka.server:type=Produce,user=([-.\w]+),client-id=([-.\w]+)
kafka.server:type=Request,user=([-.\w]+),client-id=([-.\w]+)
# Throttle metrics
kafka.server:type=FetchThrottleTime,user=([-.\w]+),client-id=([-.\w]+)
kafka.server:type=ProduceThrottleTime,user=([-.\w]+),client-id=([-.\w]+)
kafka.server:type=RequestThrottleTime,user=([-.\w]+),client-id=([-.\w]+)
MetricAlert ThresholdDescription
byte-rate> 90% of quotaApproaching limit
throttle-time> 1000 msSignificant throttling
request-percentage> 90%CPU quota approaching limit
# Producer throttle rate by user
rate(kafka_server_produce_throttle_time_total{user!=""}[5m])
# Consumer byte rate vs quota
kafka_server_fetch_byte_rate / kafka_server_fetch_byte_rate_quota

IssueSymptomSolution
Unexpected throttlingClient receives throttle responseCheck quota resolution, verify applied quota
Quota not appliedNo throttling despite high trafficVerify entity names match exactly
Wrong quota precedenceDifferent quota than expectedCheck all entity combinations
Terminal window
# List all quotas for troubleshooting
kafka-configs.sh --bootstrap-server kafka:9092 \
--describe \
--entity-type users
kafka-configs.sh --bootstrap-server kafka:9092 \
--describe \
--entity-type clients
kafka-configs.sh --bootstrap-server kafka:9092 \
--describe \
--entity-type users \
--entity-default
kafka-configs.sh --bootstrap-server kafka:9092 \
--describe \
--entity-type clients \
--entity-default
// Check producer metrics for throttling
Metric throttleTime = producer.metrics().get(
new MetricName("produce-throttle-time-avg", "producer-metrics", ...)
);