An interesting situation arises when the retries is set to non-zero and the max.in.flight.requests.per.connection is greater than one. This allows the producer to send out more than one batch of messages without having received acknowledgements for any. Consider the following scenario:
Two batches of messages are sent, one after another, destined for the same partition.
The first batch of messages fails to be written successfully at the Kafka broker.
The second batch gets written successfully.
The producer retries sending the first batch again which gets written successfully this time.
The consequence is that the ordering of messages isn’t preserved within the partition, which can be a critical requirement for some applications. In such situations max.in.flight.requests.per.connection should be set to 1, though it will severely impact the throughput of the producer.
An interesting situation arises when the retries is set to non-zero and the max.in.flight.requests.per.connection is greater than one. This allows the producer to send out more than one batch of messages without having received acknowledgements for any. Consider the following scenario:
Two batches of messages are sent, one after another, destined for the same partition.
The first batch of messages fails to be written successfully at the Kafka broker.
The second batch gets written successfully.
The producer retries sending the first batch again which gets written successfully this time.
The consequence is that the ordering of messages isn’t preserved within the partition, which can be a critical requirement for some applications. In such situations max.in.flight.requests.per.connection should be set to 1, though it will severely impact the throughput of the producer.