My understanding is that Kafka has ordering guarantees at the partition level. My question is - if your application has multiple consumers running concurrently and reading from the same partition, does the ordering in the partition even matter? After all, isn't your application going to handle it out-of-order anyway?
For example, suppose I produced 3 messages in its respective order M1, M2, M3 to a single partition P1.
M1:
{"userId": 1, "favourite_food": "chicken"}
M2:
{"userId": 1, "favourite_food": "beef"}
M3:
{"userId": 1, "favourite_food": "fish"}
Suppose I have 3 consumers C1, C2, C3 in the same consumer group. The application logic of these consumers is to save the data (sent in the message body) into the database (basically we want to save the User's favourite food in the database).
Now, since the messages are ordered within the partition itself, C1 reads M1 at time t, C2 reads M2 at time t+1, and C3 reads M3 at time t+2. However, since we are reading the messages somewhat in parallel, the ordering in which the consumers save the data into the database might be out-of-order. For example, suppose C1 runs on a very slow computer and only writes to the database at time t+10. However, C2 and C3 runs on faster computers and they write to the database at time t+5 and t+6 respectively. From the application perspective, the User's favourite food is now "chicken", although it should actually be "fish", since "fish" was the "latest" message.
My question is - How can we guarantee ordering at the application-level? And even if we could do this, why does Kafka's "ordering within a partition" even matter if we have to handle ordering at the application-level anyway?
Not sure if I'm just misunderstanding something...