Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

Define an overload-handling standard for all services in your platform covering executor rejection, request queues and responses to clients.

The standard says that every queue and pool in every service is bounded and has a documented rejection behaviour; that a rejection becomes a 503 (we are overloaded) or a 429 (you are over your quota) with a Retry-After header, never a 500; that clients retry only with exponential backoff, jitter and a retry budget; that low-priority traffic is shed before important traffic; and that every service publishes rejection and queue-depth metrics and proves its overload behaviour in load tests.

Why this question is asked

Overload is the one failure every service will meet, and it rarely stays in one place. A slow database makes one service queue requests, its callers time out and retry, the retries double the load, and soon several services are down because of one slow dependency. A platform-wide standard exists so that every service reacts to overload in the same predictable way, which is what makes the whole system recover instead of collapse. Interviewers ask this design question to see whether we understand overload as a system property. In this answer, we will recap how overload turns into an outage, then go through the five parts of the standard: bounded queues, the right responses, client retries, priorities, and the metrics and tests that keep everyone honest.

1How Overload Turns Into an Outage

A service is overloaded when work arrives faster than it can finish it. The extra work has to wait somewhere: in an executor's queue, in the web server's accept queue, in a connection pool's wait list. If those queues are unbounded, waiting time grows without limit, every request becomes slow, and memory fills up. Clients time out, but the server keeps working on requests nobody is waiting for any more, so its useful throughput, often called goodput, drops even though it is busy.

Retries make it worse. If each client retries three times on a timeout, an overloaded service can receive up to four times its normal load at exactly the moment it can handle the least. This is called a retry storm, and it is why the standard covers clients as well as servers.

2Rule 1: Every Queue and Pool Is Bounded

Every place where work can wait has a limit, and the service's documentation, or simply its configuration file, says what happens when the limit is reached. That covers executor queues, the web server's thread pool and accept queue, HTTP and database connection pools, and in-memory buffers in front of message producers. The size of each queue is chosen from the waiting time we can accept: if a pool completes 500 tasks per second and the caller's deadline leaves 200 ms for waiting, the queue holds about 100 tasks, not 100,000.

A bounded queue turns slow death into fast, honest failure. When it is full, the service rejects new work immediately, which keeps latency for accepted work low and gives callers a clear signal.

Step throughWhere work waits in one request path, each with a limit
  1. Load balancer / gatewayrate limits per client, priority tagging
  2. Web servermax threads 200, accept queue 100
  3. Service executorsbounded queues, AbortPolicy, rejection counter
  4. Client pools to dependenciesconnection limit, acquire timeout
  5. Dependencyits own limits: answers 503 or 429 when full

5 layers, from the top down. Step through them one at a time.

Overload is rejected at the first full layer instead of waiting everywhere.

3Rule 2: Rejections Become 503 or 429, Never 500

Status codes tell clients what to do next, so we use them precisely. 503 Service Unavailable means the service is temporarily overloaded and the request may succeed later. 429 Too Many Requests means this particular client has exceeded its quota. Both carry a Retry-After header, the number of seconds the client should wait. A 500 Internal Server Error means a bug, and it is the wrong answer for overload, because alerts treat it as a defect and clients cannot tell whether retrying makes sense.

In a Spring service, the standard is a shared exception handler that every service gets from the platform starter.

Java
@RestControllerAdvice
class OverloadHandler {
@ExceptionHandler(RejectedExecutionException.class) // also covers Spring's TaskRejectedException
ResponseEntity<ProblemDetail> overloaded(RejectedExecutionException e) {
ProblemDetail body = ProblemDetail.forStatusAndDetail(HttpStatus.SERVICE_UNAVAILABLE, "busy, try again");
return ResponseEntity.status(503).header(HttpHeaders.RETRY_AFTER, "2").body(body); // 503, Retry-After: 2
}
@ExceptionHandler(QuotaExceededException.class) // our rate limiter's exception
ResponseEntity<ProblemDetail> quota(QuotaExceededException e) {
return ResponseEntity.status(429).header(HttpHeaders.RETRY_AFTER, String.valueOf(e.retryAfterSeconds()))
.body(ProblemDetail.forStatus(429)); // 429, Retry-After: 30
}
}
Responses the standard allows
SituationStatusHeaderClient action
Our pool or queue is full503Retry-After: a few secondsback off, retry within budget
Client exceeded its quota429Retry-After: until quota resetswait, do not retry sooner
Dependency failed or timed out503 or 504Retry-After if knownback off, retry within budget
Bug in our code500nonedo not retry blindly

So a full pool anywhere in the service produces the same response shape, and dashboards can separate overload (503 and 429) from bugs (500).

4Rule 3: Clients Retry With Backoff, Jitter and a Budget

Retries are allowed only for idempotent requests, ones that are safe to repeat, and only on retryable responses such as 503, 429 and timeouts. Each retry waits longer than the last, which is exponential backoff, and the wait is randomised, which is jitter, so that thousands of clients that failed at the same moment do not all retry at the same moment. A client also honours Retry-After when it is present.

Java
Duration backoff(int attempt) { // attempt 1, 2, 3 ...
long capMs = Math.min(5_000, 100L << attempt); // 200, 400, 800 ... capped at 5 s
return Duration.ofMillis(ThreadLocalRandom.current().nextLong(capMs)); // full jitter: 0 .. cap
}
// attempt 1 -> somewhere in 0..200 ms, attempt 2 -> 0..400 ms, attempt 3 -> 0..800 ms

The last part is the retry budget: retries may add at most a fixed share of traffic, for example 10 percent of requests over the last minute, per client and per destination. When the budget is spent, the client stops retrying and fails fast. Notice why this matters: during a real outage almost every request fails, so per-request limits alone still multiply the load, while a budget caps the extra load at 10 percent whatever happens. The platform's shared HTTP client implements all of this, so teams configure it instead of writing it.

5Rule 4: Shed Low-Priority Work First

Not all requests are equal. Placing an order matters more than refreshing recommendations, and a user's click matters more than a background prefetch. The standard defines a small number of priority classes, for example critical, normal and best-effort, set by the gateway from the route or a header. When a service passes a utilisation threshold, such as its executor being 80 percent busy or its queue half full, it starts rejecting best-effort requests; above a higher threshold it rejects normal ones; critical requests are rejected only when there is truly no capacity left.

Batch and background work follow the same idea: they run on their own bounded pools, so they can be paused or shed without touching user traffic. The result is that during overload, the important features keep working and the less important ones degrade first.

6Rule 5: Measure It and Test It

Every service publishes, with the same names, its queue depths, active threads, rejection counts by priority, and the rate of 503 and 429 responses. Alerts fire on sustained rejections, not on single spikes. Without these numbers nobody knows whether limits are too tight or too loose.

Finally, overload behaviour is part of the load test that every service runs before major releases: push traffic to about twice the expected peak and check that latency for accepted requests stays within its target, that excess requests get fast 503s instead of timeouts, that best-effort traffic is shed first, and that the service recovers by itself when load drops. Overload behaviour that has never been tested is only a hope.

7Follow-up questions

Why 503 rather than 500 when our own pool is full?

Because the two mean different things to clients and to operators. 503 says the service is healthy but busy and the request may work later, so a client backs off and retries within its budget. 500 says something is broken, triggers bug alerts, and gives the client no guidance about retrying.

What is the difference between a retry budget and a maximum number of retries?

A maximum number of retries limits retries per request, so in a full outage each request still becomes three or four. A budget limits retries as a share of all traffic, such as 10 percent, so the extra load stays small however many requests fail. Most clients use both.

Where should load shedding happen, at the gateway or in the service?

Both. The gateway enforces per-client quotas and tags priority cheaply, before any work is done. Only the service knows its own pool and queue state, so it makes the final shedding decision based on its real utilisation.

8Conclusion

In this answer, we saw why overload spreads through unbounded queues and retry storms, and defined a standard to stop it. Every queue and pool is bounded with a documented rejection; rejections become 503 or 429 with Retry-After, never 500; clients retry only idempotent calls with exponential backoff, jitter and a retry budget; low-priority work is shed first; and every service publishes the same overload metrics and tests its behaviour at twice its peak load.

What to say in the interviewAbout 90 seconds aloud

Open with

I would build the standard around one idea: overload should be rejected early and honestly, not absorbed into growing queues. So first, every queue and pool is bounded, the executor queues, the web server threads, connection pools, in-memory buffers, and each has a documented behaviour when full, normally fail fast.

Then, if they want more

Queue sizes come from the waiting time we can afford, not from memory. Second, a rejection maps to a clear response: 503 with Retry-After when we are overloaded, 429 with Retry-After when a client exceeds its quota, and never 500, because 500 means a bug and gives the client no guidance.

The platform starter ships one exception handler that does this. Third, clients: retries only for idempotent calls and retryable responses, with exponential backoff, full jitter, respect for Retry-After, and a retry budget, say ten percent of traffic per destination, because without a budget an outage multiplies the load. That lives in the shared HTTP client.

Fourth, priorities: the gateway tags traffic as critical, normal or best-effort, and services shed best-effort first as utilisation rises, so checkout keeps working while recommendations degrade. Background work has separate pools.

Fifth, every service publishes the same metrics, queue depth, rejections by priority, 503 and 429 rates, and runs an overload test at about twice peak to prove fast rejection, protected latency and automatic recovery.

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 "Define an overload-handling standard for all services in your platform covering executor...": https://scrivio-interview-library.netlify.app/java/executors/ce78a72937/