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 Types
Section titled “Quota Types”| Quota Type | Metric | Unit | Purpose |
|---|---|---|---|
producer_byte_rate | Producer throughput | bytes/sec | Limit write bandwidth |
consumer_byte_rate | Consumer throughput | bytes/sec | Limit read bandwidth |
request_percentage | Request handler time | % of capacity | Limit CPU usage |
controller_mutation_rate | Metadata mutations | mutations/sec | Limit control plane load |
Quota Entities
Section titled “Quota Entities”Quotas can be applied to different entity combinations:
Entity Types
Section titled “Entity Types”| Entity | Description | Example |
|---|---|---|
| User | Authenticated principal | User:alice |
| Client ID | Client identifier string | producer-app-1 |
| User + Client ID | Specific user with specific client | User:alice + producer-1 |
| Default | Applies to all users/clients | <default> |
Managing Quotas
Section titled “Managing Quotas”Setting Producer Quotas
Section titled “Setting Producer Quotas”# Quota for specific userkafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --add-config 'producer_byte_rate=10485760' \ --entity-type users \ --entity-name producer-user
# Quota for specific client IDkafka-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 combinationkafka-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-producerSetting Consumer Quotas
Section titled “Setting Consumer Quotas”# Consumer quota for userkafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --add-config 'consumer_byte_rate=52428800' \ --entity-type users \ --entity-name consumer-user
# Consumer quota for client IDkafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --add-config 'consumer_byte_rate=26214400' \ --entity-type clients \ --entity-name my-consumer-appSetting Request Quotas
Section titled “Setting Request Quotas”# Limit CPU usage to 50% of one I/O threadkafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --add-config 'request_percentage=50' \ --entity-type users \ --entity-name batch-processorSetting Default Quotas
Section titled “Setting Default Quotas”# Default quota for all userskafka-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 IDskafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --add-config 'producer_byte_rate=5242880' \ --entity-type clients \ --entity-defaultViewing Quotas
Section titled “Viewing Quotas”# View quota for specific userkafka-configs.sh --bootstrap-server kafka:9092 \ --describe \ --entity-type users \ --entity-name producer-user
# View quota for specific clientkafka-configs.sh --bootstrap-server kafka:9092 \ --describe \ --entity-type clients \ --entity-name my-producer-app
# View all user quotaskafka-configs.sh --bootstrap-server kafka:9092 \ --describe \ --entity-type users
# View default quotaskafka-configs.sh --bootstrap-server kafka:9092 \ --describe \ --entity-type users \ --entity-defaultRemoving Quotas
Section titled “Removing Quotas”# Remove specific quotakafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --delete-config 'producer_byte_rate' \ --entity-type users \ --entity-name producer-user
# Remove all quotas for entitykafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --delete-config 'producer_byte_rate,consumer_byte_rate,request_percentage' \ --entity-type users \ --entity-name producer-userQuota Resolution
Section titled “Quota Resolution”When multiple quotas apply, the most specific quota takes precedence:
Resolution Order
Section titled “Resolution Order”- User + Client ID - Most specific
- User only
- Client ID only
- Default User (
--entity-default) - Default Client ID (
--entity-default) - No quota - Unlimited
Example Resolution
Section titled “Example Resolution”User: alice, Client ID: producer-1
Quota sources:1. User:alice + Client:producer-1 → 20 MB/s (APPLIED)2. User:alice → 10 MB/s3. Client:producer-1 → 5 MB/s4. Default User → 1 MB/s5. Default Client → 1 MB/s
Result: 20 MB/s (most specific match wins)Broker Configuration
Section titled “Broker Configuration”Quota Windows
Section titled “Quota Windows”# Broker configuration for quota enforcementquota.window.num=11quota.window.size.seconds=1| Setting | Default | Description |
|---|---|---|
quota.window.num | 11 | Number of samples for rate calculation |
quota.window.size.seconds | 1 | Duration of each sample window |
Controller Mutation Quotas
Section titled “Controller Mutation Quotas”# Limit metadata mutations per secondcontroller.quota.window.num=11controller.quota.window.size.seconds=1# Set controller mutation quotakafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --add-config 'controller_mutation_rate=10' \ --entity-type users \ --entity-name admin-userThrottling Behavior
Section titled “Throttling Behavior”How Throttling Works
Section titled “How Throttling Works”When a client exceeds its quota:
- Broker calculates delay based on excess usage
- Response includes
throttle_time_ms - Client pauses before next request
- Metrics track throttling events
Throttling Metrics
Section titled “Throttling Metrics”| Metric | Description |
|---|---|
produce-throttle-time | Producer throttle time (ms) |
fetch-throttle-time | Consumer throttle time (ms) |
request-time | Total request time including throttle |
Common Quota Patterns
Section titled “Common Quota Patterns”Multi-Tenant Cluster
Section titled “Multi-Tenant Cluster”# Tenant A: High prioritykafka-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: Standardkafka-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: Basickafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --add-config 'producer_byte_rate=10485760,consumer_byte_rate=20971520' \ --entity-type users \ --entity-name tenant-cApplication Tiers
Section titled “Application Tiers”# Critical applications - high quotakafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --add-config 'producer_byte_rate=104857600' \ --entity-type clients \ --entity-name 'critical-*'
# Batch jobs - limited quotakafka-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 applicationskafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --add-config 'producer_byte_rate=5242880,consumer_byte_rate=10485760' \ --entity-type clients \ --entity-defaultProtecting Control Plane
Section titled “Protecting Control Plane”# Limit admin operationskafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --add-config 'controller_mutation_rate=50' \ --entity-type users \ --entity-name admin-user
# Limit automation toolskafka-configs.sh --bootstrap-server kafka:9092 \ --alter \ --add-config 'controller_mutation_rate=10' \ --entity-type users \ --entity-name ci-cd-userQuota Sizing Guidelines
Section titled “Quota Sizing Guidelines”Producer Quotas
Section titled “Producer Quotas”| Workload | Suggested Quota | Rationale |
|---|---|---|
| High-priority | 100 MB/s | Real-time applications |
| Standard | 50 MB/s | Normal production traffic |
| Batch | 10-20 MB/s | Background processing |
| Development | 5 MB/s | Non-production |
Consumer Quotas
Section titled “Consumer Quotas”| Workload | Suggested Quota | Rationale |
|---|---|---|
| High-priority | 200 MB/s | Real-time consumers |
| Standard | 100 MB/s | Normal consumption |
| Analytics | 50 MB/s | Batch analytics |
| Monitoring | 10 MB/s | Metrics collection |
Request Quotas
Section titled “Request Quotas”| Application Type | Suggested % | Rationale |
|---|---|---|
| Critical | 100% | No throttling |
| Standard | 50-75% | Fair share |
| Batch | 25% | Background priority |
| Development | 10% | Limited resources |
Monitoring Quotas
Section titled “Monitoring Quotas”JMX Metrics
Section titled “JMX Metrics”# Per-user metricskafka.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 metricskafka.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]+)Key Metrics to Monitor
Section titled “Key Metrics to Monitor”| Metric | Alert Threshold | Description |
|---|---|---|
byte-rate | > 90% of quota | Approaching limit |
throttle-time | > 1000 ms | Significant throttling |
request-percentage | > 90% | CPU quota approaching limit |
Grafana Query Example
Section titled “Grafana Query Example”# Producer throttle rate by userrate(kafka_server_produce_throttle_time_total{user!=""}[5m])
# Consumer byte rate vs quotakafka_server_fetch_byte_rate / kafka_server_fetch_byte_rate_quotaTroubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”| Issue | Symptom | Solution |
|---|---|---|
| Unexpected throttling | Client receives throttle response | Check quota resolution, verify applied quota |
| Quota not applied | No throttling despite high traffic | Verify entity names match exactly |
| Wrong quota precedence | Different quota than expected | Check all entity combinations |
Debugging Quotas
Section titled “Debugging Quotas”# List all quotas for troubleshootingkafka-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-defaultClient-Side Debugging
Section titled “Client-Side Debugging”// Check producer metrics for throttlingMetric throttleTime = producer.metrics().get( new MetricName("produce-throttle-time-avg", "producer-metrics", ...));Related Documentation
Section titled “Related Documentation”- Configuration Overview - Configuration guide
- Broker Configuration - Broker settings
- ACL Configuration - Access control
- Monitoring - Metrics and alerting
- Performance - Performance tuning