Partitions, Keys, and Ordering
As a Senior engineer, explain Partitions, Keys, and Ordering. What problem does it solve and how would you describe it in an interview?
Answers use simple, clear English.
Quick interview answer
At Senior depth: start with the problem, then mechanism, then a short example. Ordering guaranteed per partition only.
Detailed answer
At Senior depth: start with the problem, then mechanism, then a short example. Ordering guaranteed per partition only. Key determines partition hash — same key → same partition. More partitions = more parallelism but more overhead. 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?