At Quillfern Parcels. This is the system from chapter 5 of the Quillfern story, "Every scan is an event": Tracking, billing, and customer notifications all poll the database for new scans. It slows down every afternoon, and a slow consumer delays everyone.
What the model simplifies
One partition's replicas sit on different brokers, and the worst case is assumed: every broker that is down held a replica. The in-sync set is exactly the replicas on live brokers, and unclean leader election is off. Each consumer handles 500 scans a second, and only as many consumers as there are partitions do any work. Every number on this page comes from one shared set of calculations, which the simulation questions use too, so a question can never disagree with what the simulator shows.
The drills, written out
Two brokers go down and writes stop
- Healthy state. Each scan is written to three replicas. The producer uses acks=all and the topic needs two in-sync copies, so one broker can fail with no lost scan.
- Trigger. A rack loses power during maintenance and takes broker-1 and broker-2 down together.
- What is affected. The dispatch service, which writes the scans. Readers still have broker-3.
- Symptoms. Scanners show "could not save scan" and retry; tracking pages still load, but show nothing new.
- Metrics. In-sync replicas fall to 1, below min.insync.replicas = 2. Under-replicated partitions alert; the produce error rate goes to 100%.
- Logs. The producer logs the reason.
org.apache.kafka.common.errors.NotEnoughReplicasException: Messages are rejected since there are fewer in-sync replicas than required.
- Reasoning. This is the setting working as designed: with acks=all, Kafka refuses a write it cannot store on two brokers, rather than accept it with one copy that a single crash would lose.
- Mitigation. Bring broker-2 back first. It catches up and rejoins the in-sync set: two replicas again, so writes succeed. Do not lower min.insync.replicas to 1 to get writes back: that trades an outage for silent data loss.
- Recovery. Scanners send the scans they held. With one broker still down, the topic tolerates 1 more failures until broker-1 returns.
- Prevention. Put brokers in different racks or zones (broker.rack), so one power failure cannot take two replicas, and alert on under-replicated partitions before the second failure.
Peak season: consumer lag grows
- Healthy state. Three consumers read 1,500 scans a second; the depots send 1,200, so there is no lag.
- Trigger. The holiday peak doubles the scans to 2,400 a second.
- What is affected. The tracking consumers, and so every customer looking at a parcel's status.
- Symptoms. Tracking shows parcels still "at the depot" after they are delivered. Nothing errors; it is just late.
- Metrics. Lag is 90,000 scans and growing by 900 a second: capacity is 1,500 a second against 2,400 arriving.
- Logs. The consumer group shows lag on every partition.
kafka-consumer-groups --describe --group tracking
PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG
0 4812301 4827301 15000
1 4799120 4814120 15000
...
- Reasoning. Each consumer is already at its limit. The topic has 6 partitions and only 3 consumers, so half the possible parallelism is unused.
- Mitigation. Scale the consumer group to 6, one per partition: capacity rises to 3,000 a second.
- Recovery. The backlog drains in 2 min 30 s, and tracking is current again. A seventh consumer would sit idle: partitions cap the parallelism.
- Prevention. Alert on lag growth in time, not only its size; autoscale consumers on lag; and create topics with enough partitions for the peak, because adding partitions later moves keys.
Learn it properly
All simulators · Curriculum map