Achieving Order Guarnetee in Kafka with Partitioning

One of the most important features of Kafka is to do load balancing of messages and guarantee ordering in a distributed cluster, which otherwise would not be possible in a traditional queue.

Lets first try and understand the problem statement

Let us assume we have a topic where messages are sent and there is a consumer who is consuming these messages.
If there is only one consumer, it would receive the messages in the order in which they are in the queue, or in the order in which they are sent.

Now, in order to achieve higher performance, we need to process the messages faster and hence we introduce multiple instances of the consumer application.

This would lead to a problem, if the messages contain any state.
Read More »