liveBook · Manning

Fetch.min.bytes

As explained in Apache Kafka in Action

fetch.min.bytes is a Kafka consumer setting that specifies the minimum number of bytes the broker should accumulate before responding to a fetch request.

fetch.min.bytes tells the Kafka broker to wait until a fetch response contains at least the configured number of bytes. Its default value is 1, so the broker responds when at least one byte of new messages is available. Responses contain whole batches and may contain several batches. section 6.4.1 section 9.2

The setting trades latency for bandwidth. A larger value encourages fuller responses and can improve consumer throughput, while fetch.max.wait.ms limits how long the broker waits when insufficient data arrives. Its default is 500 ms. Never set either setting to 0: immediate responses can create excessive fetch-request load, including requests issued in parallel for every partition. section 6.4.1 section 6.5

Testing a 1 MB fetch threshold

Create consumer.properties with fetch.min.bytes: 1000000 and fetch.max.wait.ms: 500, then pass it to kafka-consumer-perf-test.sh with --consumer.config. In the reported test, consuming the same 1,000,000 messages and about 9.5 GB took 13 seconds instead of 17, increasing throughput from 547 MB/s to 734 MB/s. Hardware and consumer processing speed can change the result. section 6.4.2

fetch.min.bytes: 1000000
fetch.max.wait.ms: 500

Inspect the consumer.properties values used to raise fetch.min.bytes to 1 MB and retain a 500 ms maximum wait. section 6.4.2

How Apache Kafka in Action covers it

How deep it goes
Explains defaults, batching, timeout interaction, broker flow, overload risk, and a measured performance test.
Examples
Uses default fetches, a 1 MB consumer.properties setting, kafka-consumer-perf-test.sh, and throughput results for one million messages.
What you can do after
Evaluate consumer throughput with kafka-consumer-perf-test.sh and balance fetch size, latency, wait time, and broker request load.
How it connects
Connects fetch.min.bytes with fetch.max.wait.ms, message batches, fetch requests, brokers, and consumer performance.

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.