Partitions, Keys, and Ordering
What are the key trade-offs of Partitions, Keys, and Ordering? When would you choose it vs alternatives?
Answers use simple, clear English.
Audio N/AQuick interview answer
Pros: Horizontal consumer scale; replay by offset. Cons: Cross-partition ordering impossible; hot keys imbalance partitions.
Detailed answer
Pros: Horizontal consumer scale; replay by offset. Cons: Cross-partition ordering impossible; hot keys imbalance partitions. Decision: pick when benefits outweigh operational cost. 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: Junior.
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?