CCDAK practice question 11 of 25

What is the risk of increasing max.in.flight.requests.per.connection while also enabling retries in a producer?

Full set: 150 questions
Answer options
A: At least once delivery is not guaranteed
B: Message order not preserved Correct answer
C: Reduce throughput
D: Less resilient
Correct Answer:
B. Message order not preserved
Explanation

When max.in.flight.requests.per.connection is set to a value greater than 1, the producer can send multiple batches of messages to the broker without waiting for an acknowledgment for each one. If retries are also enabled and the first batch fails due to a transient error, the producer will attempt to resend it. In the meantime, a second, subsequent batch might be sent and successfully written to the broker. When the first batch is eventually retried and succeeds, it will be written after the second batch, thus violating the original sending order.

Why Incorrect

A. At least once delivery is not guaranteed: Enabling retries is the mechanism that helps ensure at-least-once delivery by resending messages that fail.
C. Reduce throughput: Increasing max.in.flight.requests.per.connection is a standard technique to increase producer throughput by allowing more requests to be sent in parallel.
D. Less resilient: Enabling retries makes the producer more resilient to transient failures, not less.

References

1. Confluent Documentation, Producer Configuration: Under the description for max.in.flight.requests.per.connection, the documentation states: "Note that if this setting is set to be greater than 1 and there are failed sends, there is a risk of message reordering due to retries (if retries is greater than 0). If message ordering is required, set max.in.flight.requests.per.connection to 1..."

Source: Confluent Documentation, "Producer Configs for Confluent Platform".

2. Apache Kafka Documentation, Producer Configs: The official Kafka documentation provides the same warning: "Note that if this setting is set to be greater than 1 and there are failed sends, there is a risk of message re-ordering due to retries (i.e., if retries are enabled). If message ordering is required...it is recommended to set this to 1."

Source: Apache Kafka Documentation, Section 3.4 "Producer Configs".

3. Narkhede, N., Shapira, G., & Palino, T. (2017). Kafka: The Definitive Guide. O'Reilly Media. In Chapter 4, "Kafka Producers," the section "Producer Configuration" explains this interaction: "If we want to guarantee order, we’d have to set max.in.flight.requests.per.connection to 1... Otherwise, if two batches of messages are sent to a single partition, and the first fails and is retried but the second succeeds, the messages in the second batch may appear first."

Source: Chapter 4, Producer Configuration, Page 61.

Scroll to Top