liveBook · Manning

Resource limit

As explained in Apache Kafka in Action

A Kafka quota is a resource limit applied to clients or users to control request rates or broker resource consumption.

A misconfigured producer can flood a Kafka cluster with data; an uncontrolled consumer can overwhelm brokers with requests. Quotas limit client activity to protect other users and distribute resources more fairly. section 13.3

Choose a limit and an identity to apply it to:

  • Set produce and consume byte rates, or limit the broker CPU time allocated to a client. section 13.3
  • Start with a conservative default, then give clients that need more capacity specific quotas. Where authentication is available, prefer user-level quotas: clients can choose their own client IDs. section 13.3
  • Remember that enforcement is per broker. A client connected to more brokers can exceed its nominal quota across the cluster. section 13.3
kafka-configs.sh --bootstrap-server localhost:9092 \
    --alter \
    --entity-type clients \
    --entity-default \
    --add-config 'producer_byte_rate=1048576,\
    consumer_byte_rate=2097152,request_percentage=100'

This `kafka-configs.sh` command sets default client quotas: 1 MiB/s for producing, 2 MiB/s for consuming, and a request-percentage limit of 100. section 13.3

kafka-configs.sh --bootstrap-server localhost:9092 \
    --alter \
    --entity-type users \
    --entity-name warehouse \
    --add-config 'consumer_byte_rate=5242880,request_percentage=200'

A user-specific command gives the `warehouse` principal its own consume-rate and request-percentage limits. section 13.3

Monitor throttle time after setting quotas. Limits that are too aggressive can disrupt service or cause cascading failures. On managed Kafka, also watch provider-specific limits, such as network bandwidth, because hitting them can cause throttling. section 13.4 section 15.5.5

How Apache Kafka in Action covers it

How deep it goes
Explains quota types, identities, per-broker enforcement, and CLI settings, but does not develop a monitoring procedure.
Examples
Uses misconfigured producers and uncontrolled consumers to motivate limits, then shows default client and named-user `kafka-configs.sh` commands.
What it assumes
Introduces the purpose of quotas through producer and consumer behavior, then uses Kafka CLI commands without teaching CLI basics.
What you can do after
Operate/configure it with `kafka-configs.sh`, then monitor throttling and adjust limits that disrupt clients.
How it connects
Connects quotas to authentication, client throttling, broker CPU time, and throttle-time monitoring.

Also explained in

Compare how 4 books explain resource limit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.