Part 8 of 8 · 2 min read
Exercises
Easy
Easy 1: Storage (20 minutes)
20,000 messages a second, 2 KB each, kept for 7 days. Give MB per second, TB per day and total TB.
Done when: you write 40 MB per second, 3.456 TB a day and about 24.2 TB.
Hint
20,000 × 2 KB = 40,000 KB per second.
Easy 2: Share partitions (20 minutes)
A topic has 12 partitions. Show the split for a group of 5 consumers, and say how many consumers are idle in a group of 15.
Done when: you write 3, 3, 2, 2, 2 and 3 idle consumers.
Hint
Split 12 as evenly as possible.
Easy 3: Key to partition (20 minutes)
There are 4 partitions. Keys have hash values 10, 7, 22 and 15. Give each partition.
Done when: you write 2, 3, 2 and 3.
Hint
Use the remainder of dividing by 4.
Medium
Medium 1: Draw the producer and consumer flows (30 minutes)
Draw a producer with a buffer, a leader and two followers, and a consumer group with a coordinator. Number the steps.
Done when: a diagram with numbered steps for both flows and the offset commit.
Hint
The coordinator is found by hashing the group name.
Medium 2: Count duplicates (30 minutes)
A consumer committed offset 9, processed 10 to 14, then crashed before committing. How many messages are repeated under commit-after-processing, and how many are lost under commit-before-processing if it committed 14 first and crashed after handling 12?
Done when: you write 5 repeated, and 2 lost (13 and 14).
Hint
Under commit-first, offsets 13 and 14 were committed but not handled.
Medium 3: Minimum ISR (30 minutes)
A partition has 3 replicas, minimum ISR 2, ACK = all. Do writes succeed with one broker down? With two down?
Done when: you write yes and no, with the reason.
Hint
Compare the in-sync count with 2.
Hard
Hard 1: Choose settings (60 minutes)
Pick ACK, replicas, minimum ISR, and commit rule for three topics: click logs, orders and payments. Justify each.
Done when: a table of three rows with a reason on the cost of loss.
Hint
Ask how costly one lost message is.
Hard 2: Broker failure plan (60 minutes)
With 5 brokers and 3 replicas each, write the steps after broker 2 fails. Say who decides, how leaders change and what the producer sees.
Done when: a numbered plan with the controller, new leaders and a note on the retry window.
Hint
The controller picks new leaders from in-sync followers.
Hard 3: Mock interview (60 minutes)
Answer "design a distributed message queue" aloud in 35 minutes and mark yourself on the four steps. List two missed topics.
Done when: a recording, a score on each step, and two named gaps.
Hint
Use the four-step framework as a checklist.