Quick revision
The short answer
The database is the limit: it allows 30,000 writes per second, live traffic uses 20,000, so only 10,000 per second are left for the backlog, and 400 million / 10,000 is 40,000 seconds, about 11 hours; the consumers' 60,000 per second does not matter. To keep fraud fresh, start a new consumer group at the latest offsets for live traffic now, and let a catch-up group process the backlog up to the offsets where the live group started, with the database budget split explicitly and the catch-up group throttled when live lag rises. Batch writes and idempotent upserts keyed by order id make the overlap harmless, and before anything else, check retention so the oldest backlog is not deleted first.
What to remember
In this answer, we found that the database, not the consumers, sets the recovery speed: with 30,000 writes per second and 20,000 used by live traffic, 400 million records take about 11 hours. We checked retention first, kept fraud fresh by starting a live group at the latest offsets, drained the backlog with a catch-up group bounded by those offsets, split the database budget explicitly and paused catch-up when live lag rose. Batching, idempotent upserts and fewer indexes during recovery raise the effective write rate, and ordering across groups needs versioned writes or gap handling.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The database is the limit: it allows 30,000 writes per second, live traffic uses 20,000, so only 10,000 per second are left for the backlog, and 400 million / 10,000 is 40,000 seconds, about 11 hours; the consumers' 60,000 per second does not matter. To keep fraud fresh, start a new consumer group at the latest offsets for live traffic now, and let a catch-up group process the backlog up to the offsets where the live group started, with the database budget split explicitly and the catch-up group throttled when live lag rises. Batch writes and idempotent upserts keyed by order id make the overlap harmless, and before anything else, check retention so the oldest backlog is not deleted first.
Why this question is asked
Recovering from a long consumer outage is where capacity planning stops being theoretical. The tempting move is to restart the consumers at full speed and let them catch up, but that ignores both the real bottleneck and the people waiting for fresh data. Interviewers ask this scenario to see whether we can find the binding constraint with simple arithmetic, protect freshness for the consumers that need it, and avoid the trap that deletes the backlog before we reach it. In this answer, we will calculate the drain time, separate live and backlog traffic, split the database budget, raise the write rate safely, check retention, and look at ordering across the two groups.
1Finding the Real Bottleneck
A pipeline runs at the speed of its slowest stage. The consumers could process 60,000 records per second, but every record ends as a database write, and the database sustains only 30,000 writes per second. Live traffic keeps arriving at 20,000 per second and must be written too. So the capacity left for the backlog is 30,000 - 20,000 = 10,000 per second.
At 10,000 per second, 400 million records take 400,000,000 / 10,000 = 40,000 seconds, which is about 11 hours. Adding consumer pods does not change this; they would only push the database harder, raise its latency and possibly slow the live path. The plan must start from the 11-hour figure, not from the consumers' speed.
| Quantity | Rate or size | Note |
|---|---|---|
| Consumer capacity | 60,000 per second | Not the limit |
| Database capacity | 30,000 writes per second | The bottleneck |
| Live traffic | 20,000 per second | Must keep flowing |
| Left for backlog | 10,000 per second | 30,000 - 20,000 |
| Backlog | 400 million records | |
| Time to drain | 40,000 seconds | About 11 hours |
2Check Retention First
Before anything else, compare the age of the unread records with the topic's retention. The group was down for 6 hours, so its oldest unread record is already 6 hours old. The catch-up reads oldest first, but it moves through the backlog at half the speed the backlog was written, 10,000 against 20,000 per second, so the record at its position keeps getting older: records near the end of the backlog will be about 11 to 12 hours old when it reaches them. With the default 7-day retention that is safe. With a retention of 12 hours, which some high-volume topics use, or if the group already had old lag before the outage, Kafka would delete segments before the catch-up group reads them.
If there is any doubt, extend retention.ms on the topic first, for example to 3 days, with kafka-configs or the Admin API. It takes effect without a restart and costs only disk space. Doing this later, after records have been deleted, is too late.
3Separating Live From Backlog
If the existing group simply restarts, it processes the backlog in order, and the live events arriving now wait behind 11 hours of older records. Fraud checks, which need events within a minute, would be running on data 11 hours old for most of the day.
So we split the work. First, record the existing group's committed offsets per partition; this is where the backlog starts. Then start a new consumer group, orders-live, at the latest offsets, which we also record; it begins processing live events immediately, and fraud gets fresh data within seconds. Finally, run a catch-up group that starts from the old committed offsets and processes each partition only up to the offset where orders-live started, then stops. Between them, the two groups cover every record exactly once in range, and the live path never waits for the backlog.
6 messages in order. Play them, or step through them one at a time.
The live group keeps fraud fresh; the catch-up group uses only what is left of the database budget.
4Splitting the Database Budget
The two groups share one database, so the budget must be explicit: 20,000 writes per second for live and 10,000 for catch-up. The catch-up group enforces its share with a rate limiter, and a controller watches the live group's lag. If live lag rises above, say, 30 seconds of traffic, which means the database is struggling, the controller pauses the catch-up group's containers until live lag recovers. Live freshness always wins; the catch-up simply takes a bit longer.
It also helps to tell the business the plan in their terms: fraud stays current from now on, the order history in the database is complete in about 11 hours, and reports for the outage window will be accurate after that.
5Raising the Effective Write Rate
Within the database's limits there is often room to make each write cheaper. Batch writes, for example inserting 500 rows per statement, cut per-statement overhead. Make writes upserts keyed by order id, INSERT ... ON CONFLICT (order_id) DO UPDATE, so that records processed twice, for example around the boundary between the groups or after a catch-up restart, are harmless. During the catch-up, drop or defer secondary indexes on hot tables that only reporting needs, and rebuild them afterwards.
If these changes raise the database's sustainable rate from 30,000 to, say, 40,000 per second, the catch-up budget doubles to 20,000 and the drain time falls from 11 hours to about 5.5. Measure that on a staging copy before relying on it.
6Follow-up questions
How would the plan change if records for one order must be applied in order across the two groups?
Splitting by offset means the live group can apply a newer event for order 81 before the catch-up group applies an older one. If each record carries the full current state with a version, we can make writes conditional, updating only when the incoming version is higher than the stored one, so the late older event is ignored and order no longer matters. If records are deltas that must be applied in sequence, the live group must detect gaps, for example by storing the last applied sequence number per order, and park events for orders whose earlier events are still in the backlog, applying them after the catch-up passes. If neither is possible, we keep one group and accept stale fraud data, or feed fraud from a separate live group that reads but does not write.
Why not just add database capacity?
If the database can be scaled quickly, such as a bigger instance or more provisioned throughput, that directly shortens the drain time and is worth doing. But it rarely happens in minutes, and the plan above works with the capacity we have.
What if the catch-up group crashes halfway?
It commits offsets as it goes, so it resumes from its last commit. Upserts make the few re-processed records harmless.
7Conclusion
In this answer, we found that the database, not the consumers, sets the recovery speed: with 30,000 writes per second and 20,000 used by live traffic, 400 million records take about 11 hours. We checked retention first, kept fraud fresh by starting a live group at the latest offsets, drained the backlog with a catch-up group bounded by those offsets, split the database budget explicitly and paused catch-up when live lag rose. Batching, idempotent upserts and fewer indexes during recovery raise the effective write rate, and ordering across groups needs versioned writes or gap handling.
Open with
First I would do the arithmetic, because the database is the bottleneck, not the consumers. It sustains 30,000 writes a second and live traffic needs 20,000, so only 10,000 a second are left for the backlog. 400 million divided by 10,000 is 40,000 seconds, about 11 hours, and the consumers' 60,000 a second does not change that.
Then, if they want more
Before anything else, I would check retention: if the oldest unread records are close to retention.ms, I would extend retention on the topic, otherwise they get deleted before we reach them. For fraud, if one group handles everything, live events wait behind 11 hours of backlog.
So I would record the old group's committed offsets, start a new group at the latest offsets for live traffic straight away, and run a catch-up group from the old offsets up to where the live group started.
I would split the database budget explicitly, 20,000 for live and 10,000 for catch-up, and pause or throttle the catch-up group whenever live lag rises. To speed things up safely I would batch writes, use upserts keyed by order id so any overlap between the groups is harmless, and drop non-essential indexes on hot tables during the catch-up. Every bit of extra database capacity goes straight into a shorter drain time.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Kafka documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Live traffic is 20,000 records per second, the consumers could process 60,000 per...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-design/b870e51b9d/