A Kafka topic must keep events for each order in order, and handle 100k events per second across many consumers. What do you do?
Show answer
Answer
Use the order id as the partition key
Kafka guarantees order only within a partition, and keying by order id sends all events of an order to one partition while different orders spread across many. One partition preserves order but caps throughput at one consumer. Sorting by timestamp in consumers breaks with clock skew and events in flight. Extra consumers beyond the partition count sit idle.
Source: Apache Kafka Documentation