Quick revision
The short answer
Log volume rises with failures, so the worst storms arrive during incidents; a pipeline sized for normal peaks that processes strictly in order serves 40-minute-old logs while new ones wait. We design for storms by protecting freshness, with a separate low-latency path for errors and newest-first processing while the backlog drains later, by limiting at the source with per-service rate limits, collapsed duplicate messages and one stack trace per error type per interval, by absorbing bursts without loss in a partitioned log with autoscaling on lag and shedding debug logs first, and by giving responders metrics and traces that do not depend on logs.
What to remember
In this answer, we saw that log volume rises with failures, so a pipeline sized for normal peaks and processing strictly in order falls furthest behind during incidents. We protected freshness with a separate error path and live-first processing, cut storm volume at the source with rate limits, collapsed duplicates and one stack trace per error type per interval, absorbed what remained in Kafka with autoscaling on lag and deliberate shedding of debug logs, and gave responders metrics, traces and alerts on pipeline lag that do not depend on logs.
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.
Log volume rises with failures, so the worst storms arrive during incidents; a pipeline sized for normal peaks that processes strictly in order serves 40-minute-old logs while new ones wait. We design for storms by protecting freshness, with a separate low-latency path for errors and newest-first processing while the backlog drains later, by limiting at the source with per-service rate limits, collapsed duplicate messages and one stack trace per error type per interval, by absorbing bursts without loss in a partitioned log with autoscaling on lag and shedding debug logs first, and by giving responders metrics and traces that do not depend on logs.
Why this question is asked
Every engineer who has been through a big outage has met this: you open the log search to see what is happening, and the newest line is from before the incident started. It feels like bad luck, but it is a predictable property of how logging behaves under failure. Interviewers ask this to see whether we understand that load on observability is correlated with the incidents it serves, and whether we can design for freshness rather than only for throughput. In this answer, we will explain why the pipeline fell behind, then protect freshness, limit volume at the source, absorb bursts safely, and make sure responders have signals that do not depend on logs at all.
1Why the Pipeline Failed When It Was Most Needed
During the database outage, every request failed, and every failure logged a stack trace of perhaps 5 to 10 KB. Volume went from 25 MB/s to 400 MB/s, sixteen times normal. The pipeline had been sized for normal peaks, say 120 MB/s of processing capacity, which is comfortable on any ordinary day.
Now look at what happens in a strictly ordered pipeline. Input arrives at 400 MB/s and leaves at 120 MB/s, so the backlog grows by 280 MB every second. Because processing is first in, first out, each new line waits behind everything already queued: the lag in time grows by about 0.7 seconds every second. After roughly an hour of storm, the line being processed is 40 minutes old. The pipeline lost no data; it simply served history while engineers needed the present.
The deeper point is that log volume is correlated with failure. Normal peaks come from traffic; the worst peaks come from errors, and errors come from incidents. A pipeline sized for normal peaks will always fail during the incidents that matter most.
2Protecting Freshness
The first design change is to stop treating all logs as one ordered queue. Error and warning logs go to a separate low-latency path, their own Kafka topic with its own processors and enough headroom, so the lines responders need most arrive in seconds even when everything else is backed up.
For the bulk path, we prefer the newest data during a backlog. When lag passes a threshold, say 2 minutes, processors start a second consumer at the latest offset that handles live data first, while the original consumer keeps draining the backlog with the remaining capacity. Engineers see current logs immediately, and the older ones fill in later, which is exactly the order in which they are useful.
- Source limitsrate limits, collapsed duplicates, one trace per error type
- Agentsbuffer locally, drop debug first under pressure
- Kafka topicserrors topic and bulk topic, 24 h or more retention
- Processorserrors path with headroom; bulk path live-first, backlog later
- Storage and searchfresh errors in seconds, backlog fills in
5 layers, from the top down. Step through them one at a time.
3Limiting at the Source
Most storm volume is the same message repeated thousands of times per second. Sending all of it is pure waste, so we limit it where it is produced. Each service has a rate limit per log level enforced in its agent or logging library. Agents collapse identical consecutive messages into one line with a count. And applications log a full stack trace once per error type per interval, with a counter for the rest.
Notice that nothing is hidden: the count says how often the error happened, and the metric for errors carries the exact rate. What disappears is 1,999 copies of an identical 8 KB stack trace per second. In this outage, a rule like this alone would have cut the storm from 400 MB/s to a small fraction of it. The check and the update are not atomic here, so two threads may occasionally both log a full trace, which is harmless for this purpose.
4Absorbing Bursts Without Loss
Whatever still arrives must be absorbed, not dropped. A partitioned durable log such as Kafka with enough retention, 24 hours or more, holds the backlog safely, and enough partitions let processors scale out. Processors autoscale on consumer lag, adding instances when lag grows, which needs the processing tier to be stateless and the partition count to be high enough to use the new instances.
When even that is not enough, we shed load deliberately, in priority order, rather than letting the system decide by accident.
- Lag above 2 minutes?per topicYesStart live-first consumer, autoscaleNoNormal processing
- Still growing after scaling?lag trend over 5 minutesYesDrop DEBUG, then sample INFONoKeep everything
- Errors path within 30 s?freshness targetYesHoldNoPage the platform on-call
3 steps in order. Play them, or step through them one at a time.
Shedding debug and sampling info logs from noisy services keeps errors and warnings complete. The rules are written down in advance, so nobody has to invent them during an incident.
5Signals That Do Not Depend on Logs
Logs should be the detail, not the first signal. Error rates, latency and saturation come from metrics, which have a fixed cost per series regardless of how many errors occur, and traces show where a request failed. During this outage, a metric of database connection errors per service would have told responders what was wrong within a minute, whatever the log pipeline was doing.
Finally, the log pipeline is itself monitored. We alert on consumer lag per topic and on the age of the newest searchable line, for example when errors are more than 60 seconds stale. Responders then know immediately that logs are behind, instead of drawing conclusions from an incomplete picture.
6Follow-up questions
Why not simply provision the pipeline for 16 times normal volume?
It would be idle and expensive almost all the time, and the next incident might be 30 times normal. Limiting at the source removes most of the storm's volume, and a durable log plus autoscaling absorbs the rest. Capacity should cover normal peaks with headroom; storms are handled by design, not by size.
Does collapsing duplicate messages lose information?
It loses copies, not information, as long as the collapsed line carries the count and the first and last time. For error rates, metrics are the accurate source anyway.
How do we test this?
Replay a recorded storm, or generate one in staging at 15 to 20 times normal volume, and measure the freshness of the error path, the lag of the bulk path and whether shedding happens in the intended order.
7Conclusion
In this answer, we saw that log volume rises with failures, so a pipeline sized for normal peaks and processing strictly in order falls furthest behind during incidents. We protected freshness with a separate error path and live-first processing, cut storm volume at the source with rate limits, collapsed duplicates and one stack trace per error type per interval, absorbed what remained in Kafka with autoscaling on lag and deliberate shedding of debug logs, and gave responders metrics, traces and alerts on pipeline lag that do not depend on logs.
Open with
It failed because log volume is correlated with failure. During the database outage every request logged a stack trace, so volume went sixteen times above normal, while the pipeline was sized for normal peaks and processed strictly in order.
Then, if they want more
Input exceeded capacity, the backlog grew every second, and each new line waited behind all the old ones, so after an hour engineers were looking at logs forty minutes old. I would redesign it in four ways.
First, protect freshness: errors and warnings get their own topic and processors with headroom, and when lag passes a threshold the bulk path processes the newest data first and drains the backlog later.
Second, limit at the source: per-service rate limits, agents that collapse repeated identical messages into a count, and code that logs a full stack trace once per error type per minute with a suppressed counter, which removes most of the storm.
Third, absorb the rest without loss: Kafka with at least a day of retention, processors that autoscale on lag, and a written shedding order, debug first, then sampling info, never errors.
Fourth, make sure responders do not depend on logs for the first signal: metrics and traces show error rates and where requests fail, and we alert on the pipeline's own lag and on how stale the newest searchable error is, so people know when logs are behind.
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 official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
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 "Why did the log pipeline fail exactly when it was most needed, and how do you design it...": https://scrivio-interview-library.netlify.app/architecture/system-design-problems/1c2bef1cf8/