I was going through kafka
documentation and came across
Guarantees
At a high-level, Kafka gives the following guarantees:
Messages sent by a producer to a particular topic partition will be appended in the order they are sent. That is, if a record M1 is sent by the same producer as a record M2, and M1 is sent first, then M1 will have a lower offset than M2 and appear earlier in the log. A consumer instance sees records in the order they are stored in the log. For a topic with replication factor N, we will tolerate up to N-1 server failures without losing any records committed to the log.
I had few questions.
M1
will have a lower offset than M2
? what if M1
is retried later than M2
?A possible scenario even with a single partition is:
M1
M2
M1
is not ack'ed on the first try due to some failureM2
is deliveredM1
is delivered in a subsequent try.One easy way to avoid this is through the producer config max.in.flight.requests.per.connection=1
.
This of course has performance implications, so it should be used with caution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With