Partitions, Keys, and Ordering
Design a small subsystem that relies on Partitions, Keys, and Ordering. Outline components, data flow, failure modes, and metrics.
Answers use simple, clear English.
Audio N/AQuick interview answer
Use Partitions, Keys, and Ordering as the core idea. Example shape: Order events keyed by orderId so all status updates for one order stay ordered..
Detailed answer
Use Partitions, Keys, and Ordering as the core idea. Example shape: Order events keyed by orderId so all status updates for one order stay ordered.. Watch for: Cross-partition ordering impossible; hot keys imbalance partitions.. Measure success via latency/error/saturation. 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?