CCDAK practice question 10 of 25

Your producer is producing at a very high rate and the batches are completely full each time. How can you improve the producer throughput? (select two)

Full set: 150 questions
Answer options
A: Enable compression Correct answer
B: Disable compression
C: Increase batch.size Correct answer
D: Decrease batch.size
E: Decrease linger.ms Increase linger.ms
Correct Answer:
A. Enable compression; C. Increase batch.size
Explanation

To improve producer throughput when batches are already full, the two most effective strategies are increasing the batch size and enabling compression. Increasing batch.size allows more records to be sent in a single network request, which reduces per-message overhead and improves overall throughput. Enabling compression (e.g., setting compression.type to snappy, lz4, or zstd) reduces the size of the data sent to the brokers. This decrease in data size allows for more effective data transfer over the network, significantly boosting throughput, especially if network bandwidth is a bottleneck.

Why Incorrect

B. Disable compression: This would increase the amount of data sent over the network for the same number of messages, thereby decreasing throughput.
D. Decrease batch.size: This would result in more frequent, smaller network requests, increasing the relative overhead and reducing overall throughput.
E. Decrease linger.ms: Since batches are already full, the producer is sending as soon as batch.size is reached, not waiting for linger.ms. Decreasing it would have no effect.
F. Increase linger.ms: This is irrelevant because the producer sends when a batch is full. The linger.ms timeout is not being hit, so changing it will not affect performance in this scenario.

References

1. Confluent Documentation, Producer Configs for Apache Kafka®:

batch.size: "A larger batch size will generally lead to better compression and higher throughput at the cost of more memory and higher latency." This directly supports increasing the batch size for better throughput.

compression.type: "Specify the compression type for all data generated by the producer... Compression is for the entire batch of records...". Enabling compression reduces the payload size, which is a standard technique for improving throughput.

linger.ms: "The producer will wait for up to the given delay to allow other records to be sent so that the sends can be batched together." This confirms that linger.ms is a time-based trigger, which is superseded when the size-based trigger (batch.size) is met first, as described in the question.

Source: Confluent Documentation, "Producer Configs", sections on batch.size, compression.type, and linger.ms.

2. Book: Kafka: The Definitive Guide, 2nd Edition (by Neha Narkhede, Gwen Shapira, Todd Palino)

Chapter 4: Kafka Producers: Writing Messages to Kafka: "The combination of linger.ms and batch.size are the two most important configuration parameters for controlling the producer’s throughput and latency... To increase throughput, you will want to increase both linger.ms and batch.size." (p. 78). The text further explains that when the producer is under high load (as implied by the question), batches will fill up quickly, and increasing batch.size is a key tuning parameter.

3. Confluent Developer Blog: How to Tune Your Apache Kafka Producers for High Throughput

"To achieve high throughput, you want to configure your producers to send messages in big batches. Two settings are important for this: batch.size and linger.ms... A larger batch size is generally a good thing, as it will increase throughput." This article explicitly recommends increasing batch.size for throughput. It also states, "Another way to increase throughput is to add compression," confirming the validity of enabling compression.

Source: Confluent Developer, "How to Tune Your Apache Kafka Producers for High Throughput", May 20, 2020.

Scroll to Top