Why global ordering is expensive
coreintermediateGlobal ordering means every event in a system, across every partition, every producer, and every machine, can be placed in one single, agreed-upon sequence — event 1 happened before event 2, which happened before event 3, no exceptions, no ambiguity, regardless of which server produced which event. Guaranteeing this is expensive because it requires coordination: every producer has to agree, in real time, on its position in one global sequence, which typically means funneling all writes through a single point (eliminating the parallelism a distributed system exists to provide) or running an expensive consensus protocol on every single event. This is why most real distributed messaging systems (Kafka included) deliberately do not offer global ordering as a default guarantee — instead, they guarantee ordering only within a partition (or equivalently, within all events sharing the same key), which is dramatically cheaper because a single partition can be owned and sequenced by one machine independently of every other partition, with no cross-partition coordination needed at all. The trade-off is real: two events for the same key are strictly ordered, but two events for different keys have no defined relative order, even if one was produced well before the other in wall-clock time. Most real workloads do not actually need global ordering — they need ordering per-entity (all changes to order #42 must apply in the order they happened; the relative order of a change to order #42 versus order #99 usually does not matter) — and partition-level ordering delivers exactly that, at a small fraction of the cost.
Think of it as
A large restaurant kitchen with twelve separate stations (grill, salad, dessert, ...), each producing its own dishes in the order tickets arrive at that station — the grill station's dishes come out strictly in the order the grill tickets were received, and the salad station's dishes come out strictly in the order salad tickets were received, but there is no rule at all about whether a specific grill dish comes out before or after a specific salad dish ordered around the same time. Enforcing a single global sequence — every dish in the entire kitchen numbered and produced in exactly that overall order, across all twelve stations — would require every station to constantly check in with a central coordinator before plating anything, destroying the entire point of having twelve stations working in parallel. The kitchen works because almost no one actually cares whether their salad came out before or after another table's dessert; they care that their own dish, from start to plating, happened in the right internal sequence.
What we're doing: Trace order #42's and order #99's events through a partitioned topic and confirm which orderings are actually guaranteed.
- 5
- This is the actual guarantee a consumer can rely on: every event for the same order ID arrives in the exact sequence it was produced, because the partition key ties them to the same partition and Kafka orders within a partition strictly.
- 14
- This is the guarantee that does NOT exist, and it is fine that it does not — no part of a typical order-processing application ever needs to know whether order 42's payment happened before or after order 99's cancellation, because the two orders are independent entities.
Why this works: The design only works because the partition key (order_id) was chosen to match the actual unit the application needs ordering for — if events had instead been partitioned by, say, a round-robin scheme unrelated to order_id, two events for the same order could land in different partitions and lose the exact ordering guarantee the application actually depends on.
Partitioning by a field unrelated to the entity that needs ordering
Wrong
Better
What you see: A consumer processing OrderShipped before OrderCreated for the same order, because the two events happened to fall into different one-minute timestamp buckets and were routed to different partitions with no ordering relationship between them.
Why: Partitioning "for even distribution" by an arbitrary field optimizes for a real but secondary concern (spreading load evenly across partitions) while silently discarding the one ordering guarantee the application actually needed — a partition key has to be chosen for the entity whose events must stay in order, with load distribution as a secondary constraint satisfied by having enough distinct entity keys, not the primary one.
- Global ordering
- Every event across every partition placed in one sequence
- Requires a single coordination point or a consensus protocol per event
- Throughput bounded by that coordination cost
- Rarely what the application actually needs
- Partition-level ordering
- Events for the same key strictly ordered
- No coordination needed across partitions
- Throughput scales with partition count
- Matches the common real need: per-entity ordering
Global ordering vs. partition-level ordering
Remember: Global ordering (one sequence across the entire system) requires expensive coordination and is rarely what a real workload needs. Partition-level (or key-level) ordering — strict order within the same key, no guarantee across different keys — is what most systems, including Kafka, actually guarantee by default, and it is enough for the common real requirement: ordering per entity. Choose the partition key to match the entity that actually needs ordering, not for load distribution alone.
See also: tolerating duplicates and out of order events · partitioning as a decision · the four named models

