1.Why global ordering is expensive
Global 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.
Key features
- Global ordering requires coordination across every producer and every partition, which either funnels writes through a single point (destroying parallelism) or requires an expensive consensus protocol on every event
- Partition-level (or key-level) ordering is what most real messaging systems, including Kafka, actually guarantee by default — one partition is owned by one machine at a time and sequences its own events independently, with zero cross-partition coordination
- Two events for the same key/partition are strictly ordered; two events for different keys/partitions have no defined relative order, even if one was genuinely produced first in wall-clock time
- Most real workloads only need per-entity ordering (all updates to the same order, the same account, the same document must apply in sequence) — which partition-level ordering delivers directly, by keying events on that entity's ID
- Choosing a partition key is therefore a real design decision with ordering consequences: keying events by order ID guarantees order-level ordering; keying by a coarser or unrelated field can silently lose the ordering guarantee an application actually depends on
- A system that genuinely needs global ordering across everything (rare) pays for it with a single point of coordination and reduced throughput — the cost is not hypothetical, it is the direct trade for a stronger guarantee than most workloads require
Global ordering vs. partition-level ordering
- 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
Command
# Partitioning by entity key: order-level ordering
# without any global coordination
producer.send(topic="order-events", key=order_id,
value=event)
# All events for order_id=42 land in the same
# partition and are strictly ordered relative to
# each other. Events for order_id=99 may land in a
# different partition and have no defined ordering
# relative to order_id=42's events -- which is fine,
# because nothing in the application logic ever
# needs to compare the relative order of two
# different orders.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.