What Kafka Guarantees About Order
Get precise about where ordering holds, where it does not, and how to design keys around it.
Open this lesson in the learning hubKey points
- Order is guaranteed within a partition and nowhere else. There is no such thing as global topic ordering.
- So: same key gives same partition gives ordered. Records with different keys may be processed in any order.
- Retries could reorder records, except the producer is idempotent by default since Kafka 3.0, which preserves order across in-flight batches.
- Adding partitions rehashes keys. For a short window one key can exist in two partitions, so old and new events interleave.
- Multithreading inside a consumer breaks order too, unless each thread owns whole partitions or you shard threads by key.
- If total ordering is truly required, you need one partition, and therefore one consumer. That is a throughput decision.
Order exists per partition. Choose keys as if ordering depends on them, because it does.
This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Kafka course, and every lesson in it is listed on the Kafka contents page.