Resi Dwi Thawasa

TIL

Events that must stay ordered go in the same Kafka topic

Kafka only guarantees order within a single partition. Not across partitions, and definitely not across topics.

We had two event types that had to keep a fixed relative order (something like “created” always before “updated”). They lived in separate topics, and consumers sometimes saw them out of order. Of course they did, Kafka never promised otherwise.

The fix: put both types in the same topic and give them the same key. Same key means same partition, and same partition means ordered.

So the rule I keep now: if A must come before B, they share a topic and a key. If you do not care about their relative order, separate topics are fine.

#kafka #messaging