Partitions, Keys, and Ordering
Go deep on Partitions, Keys, and Ordering: edge cases, scalability limits, and how you'd evolve the solution over 2 years.
Answers use simple, clear English.
Quick interview answer
Ordering guaranteed per partition only. Key determines partition hash — same key → same partition.
Detailed answer
Ordering guaranteed per partition only. Key determines partition hash — same key → same partition. More partitions = more parallelism but more overhead. Scale limits often appear in: Cross-partition ordering impossible; hot keys imbalance partitions.. Evolution levers: Choose key for locality; monitor per-partition lag; plan partition count upfront.. Anchor example: Order events keyed by orderId so all status updates for one order stay ordered. Core: Ordering guaranteed per partition only. Key determines partition hash — same key → same partition. More partitions = more parallelism but more overhead. Real-time example: Order events keyed by orderId so all status updates for one order stay ordered. Pros: Horizontal consumer scale; replay by offset. Cons: Cross-partition ordering impossible; hot keys imbalance partitions. Common mistakes: Assuming global order; too few partitions limiting throughput. Best practices: Choose key for locality; monitor per-partition lag; plan partition count upfront. Audience level: Senior.
Full explanation
Ordering guaranteed per partition only. Key determines partition hash — same key → same partition. More partitions = more parallelism but more overhead.
Real example & use case
Order events keyed by orderId so all status updates for one order stay ordered.
Pros & cons
Pros: Horizontal consumer scale; replay by offset. Cons: Cross-partition ordering impossible; hot keys imbalance partitions.
Common mistakes
Assuming global order; too few partitions limiting throughput.
Best practices
Choose key for locality; monitor per-partition lag; plan partition count upfront.
Follow-up questions
- How would you test Partitions, Keys, and Ordering?
- What metrics prove Partitions, Keys, and Ordering is healthy in prod?
- How does Partitions, Keys, and Ordering change at 10× traffic?