Scrivio Interview library
DesignPrincipal7 min read · updated 12 November 2026

Your company's data flows (APIs, event streams, batch feeds) have no consistent way of handling overload: some drop data, some buffer until memory runs out. Describe a company-wide approach to flow control and overload that will hold up as traffic grows over years.

We make overload behaviour a required, written part of every component's design: when demand exceeds capacity, each one must either slow its producer, shed load with a clear rejection, or queue with a fixed bound. Unbounded buffering is banned, boundaries use flow-control mechanisms that can push back (HTTP 429 and 503, consumer pause, Reactive Streams demand, credit-based protocols), load tests include deliberate overload, and every place where data may be lost is a decision the business has signed off.

Why this question is asked

Overload is not an unusual event. Every system meets a traffic spike, a slow dependency or a backlog after an outage, and what happens next is decided by whatever each component does by default. In most companies those defaults differ: one service drops messages silently, another buffers in memory until it crashes, a third retries so aggressively that it makes the overload worse. Interviewers ask this at the most senior level because the answer is not a library choice but a company-wide rule that has to survive years of growth and staff turnover. In this answer, we will look at why inconsistent defaults fail, define the three allowed behaviours, show how they apply at each kind of boundary, and then cover testing, data-loss decisions and how to roll the standard out.

1Why Inconsistent Defaults Fail

Flow control, the general name for how a producer and a consumer agree on speed, is only as strong as its weakest link. Suppose an API gateway accepts every request, passes it to a service that queues work in an unbounded in-memory list, which in turn publishes to a topic consumed by a batch loader. When the batch loader slows down, nothing pushes back: the service's queue grows, its garbage collector pauses get longer, its latency rises, the gateway's clients time out and retry, and the retries double the load. The first visible symptom is often in a component that was perfectly healthy.

The pattern is the same every time. A component that cannot say no hides overload inside itself until it fails, and its failure spreads. So the company-wide approach starts from one rule: every component must be able to say no, slow down its producer or set a limit, and must say which.

2The Three Allowed Behaviours

Every component's design note answers one question: what do you do when demand exceeds your capacity? There are only three acceptable answers. The first is to slow the producer, which works when the producer can wait: a Kafka consumer pauses, a Reactive Streams subscriber stops requesting, a TCP connection's window closes. The second is to shed load, which means refusing work quickly and clearly, for example with HTTP 429 Too Many Requests or 503 Service Unavailable and a Retry-After header, so callers back off instead of waiting. The third is to queue with a bound, accepting a known amount of extra work, say 10,000 messages or 30 seconds of traffic, and applying the first or second behaviour when the bound is reached.

Unbounded buffering is not on the list, because it is not a behaviour. It postpones the decision until memory or disk runs out, and then the decision is made for us, usually as a crash that loses everything in the buffer at once.

Overload behaviour by boundary
BoundaryPreferred behaviourMechanism
Public or partner APIshed load earlyrate limits, 429 or 503 with Retry-After
Service to service callshed load, caller backs offconcurrency limits, timeouts, retry budgets
Event stream consumerslow the producerpause partitions, bounded prefetch, lag alerts
In-process pipelineslow the producerReactive Streams demand, bounded executors
Batch feedqueue with a boundstaging area with size limit, scheduled windows
Telemetry and analyticsshed load (agreed loss)sampling, drop with counters
Every row names a bound or a rejection; none says buffer until memory runs out.

3Applying the Rule at Each Kind of Boundary

Inside a process, the standard asks for bounded executors and bounded queues: a ThreadPoolExecutor with an ArrayBlockingQueue of fixed size and a rejection policy, or reactive pipelines whose buffers have explicit sizes. Between services, the caller sets timeouts and a retry budget (for example, retries may add at most 10 percent extra load), and the callee limits concurrency and rejects with 503 rather than accepting work it cannot finish before the caller's timeout. A request that will time out anyway is pure waste, so rejecting it early is cheaper for everyone.

For event streams, the consumer pulls, so it can slow down by pausing, and the broker's retention is the bounded queue. The standard then requires that retention is long enough to absorb the longest outage we plan for, for example three days, and that lag has an alert. For credit-based protocols, such as AMQP prefetch limits or HTTP/2 flow-control windows, the standard asks teams to set the credit explicitly instead of trusting a default that may be unlimited.

4Testing Overload, Not Just Peaks

Most capacity plans test the expected peak, say 2,000 requests per second, and stop when the system passes. That tells us nothing about what happens at 4,000. The standard therefore requires an overload test for each critical path: drive it to twice its rated capacity, and separately slow down one dependency to a tenth of its normal speed, then check that the component behaves as its design note says. Latency for accepted work should stay within its target, rejections should be fast, memory should stay flat, and the system should recover on its own within minutes once the load drops.

The reason for testing the slow-dependency case separately is that it is the most common real overload and the one that exposes hidden unbounded queues. A component that looks fine at double traffic can still fall over when the database it calls slows down.

Step throughReviewing a component's overload design
  1. Rated capacity measuredfor example 2,000 requests per second
  2. Does it slow, shed or queue with a bound?
    YesCheck the bound and the mechanismNoReject the design note
  3. Run at 2x capacityaccepted latency on target, memory flat
  4. Slow one dependency to 10 percentno hidden unbounded queue
  5. Does it recover alone after load drops?
    YesApprove and record the numbersNoFix and test again

5 steps in order. Play them, or step through them one at a time.

5Making Data-Loss Decisions Explicit

Shedding load sometimes means losing data, and that is a business decision, not an engineering default. The standard asks each team to classify its data: data that must never be lost, such as payments and orders, where the only acceptable behaviours are slowing the producer or rejecting with an error the caller must handle; data that may be delayed but not lost, such as notifications, where a bounded queue backed by durable storage is right; and data that may be sampled or dropped under pressure, such as metrics and click analytics, where we drop with a counter. The product owner signs off on the class, and the dashboards show how much was dropped, so loss is visible rather than silent.

6Rolling It Out and Keeping It for Years

A standard that lives only in a wiki fades. We make it part of the paved road: shared client libraries with sensible timeouts and retry budgets, a service template whose executors and buffers are bounded by default, gateway rate limits configured per consumer, and a design-review checklist item that asks the overload question. Existing systems are brought in by risk, starting with the paths whose failure costs the most. Each year, as traffic grows, the overload tests are rerun against the new rated capacity, and the bounds are revisited, because a queue sized for last year's peak may be the next incident.

7Follow-up questions

Is a big Kafka topic an unbounded buffer?

No, as long as retention and disk are planned. A topic with three days of retention is a bounded queue measured in time, and it is durable, so a consumer that slows down loses nothing within that window. The bound becomes a problem only if nobody watches lag, because a consumer that falls behind for longer than the retention silently loses the oldest records.

Why prefer 429 or 503 over just letting requests wait?

A waiting request holds a connection, a thread or memory on every hop, and if the caller times out after two seconds, any work done after that is wasted. A fast rejection costs almost nothing, tells the caller to back off, and keeps latency low for the requests we did accept. Clients then need a retry policy with backoff and jitter so the rejections do not turn into a retry storm.

How do you stop retries from making overload worse?

With retry budgets and backoff. Each client may retry only a small share of its traffic, for example 10 percent, uses exponential backoff with jitter, and honours Retry-After. Only idempotent operations are retried automatically, and a circuit breaker stops calls to a dependency that is clearly failing.

8Conclusion

In this answer, we built a company-wide approach to overload around one rule: every component states whether it slows its producer, sheds load with a clear rejection, or queues with a fixed bound, and unbounded buffering is not allowed. We matched those behaviours to each kind of boundary, from public APIs to event streams and in-process pipelines, required overload tests at twice capacity and with a slowed dependency, made data loss an explicit business decision with visible counters, and kept the standard alive through templates, shared libraries and yearly reviews.

What to say in the interviewAbout 100 seconds aloud

Open with

I would start from the observation that overload always happens, so the only question is whether each component's behaviour is designed or accidental. The company rule would be that every component's design states what it does when demand exceeds capacity, and there are three allowed answers.

Then, if they want more

It can slow its producer, like a Kafka consumer pausing or a reactive subscriber not requesting more. It can shed load by rejecting quickly, with a 429 or a 503 and a Retry-After header, so callers back off.

Or it can queue with an explicit bound, a number of messages or a time window, and then fall back to one of the other two. Unbounded buffering is banned, because it just postpones the decision until memory runs out and then loses everything at once.

At boundaries I would push teams to mechanisms that can actually push back: Reactive Streams demand, consumer pause, credit-based protocols with explicit limits, concurrency limits and timeouts with retry budgets between services. Capacity planning would include overload tests, running at twice rated capacity and with one dependency slowed to a tenth, and checking latency, memory and recovery.

Data loss would be classified with the business: payments may never be dropped, notifications may be delayed, analytics may be sampled, and anything dropped is counted on a dashboard. To make it last for years, I would build it into the service template and shared clients, add the overload question to design review, and rerun the tests as traffic grows.

About this answer

Last updated
12 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.
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 "Your company's data flows (APIs, event streams, batch feeds) have no consistent way of...": https://scrivio-interview-library.netlify.app/spring-boot/reactive-fundamentals/d3deb654cf/