Sobes.tech
Junior — Middle

Why is it impossible to guarantee message order when using a topic divided into three partitions?

sobes.tech AI

Answer from AI

In a topic divided into several partitions (in this case three), messages are distributed among partitions, usually based on the message key or in a round-robin fashion. Each partition guarantees the order of messages within itself, but the order between different partitions is not guaranteed, as they are processed in parallel and independently.

Therefore, if messages go to different partitions, the overall order of messages when reading from the topic may differ from the order of their sending, since the consumer reads from all partitions simultaneously, and the processing speed of messages in each partition may vary.

Example: if message 1 goes to partition 0, and message 2 to partition 1, the consumer may receive message 2 before message 1, even though message 1 was sent earlier.

Why is it impossible to guarantee message order when… - sobes.tech