Quick revision
The short answer
The service is busy doing dead work: requests wait in Tomcat's connection queue for more than 2 seconds before a thread picks them up, so their clients have already given up, and throughput looks healthy while goodput, the useful completions, is near zero. Large queues turn a short overload into long waits for everyone. We fix it by bounding the waiting, with a much lower server.tomcat.max-connections than the default 8192, a small accept-count and a concurrency limiter that rejects excess with 503 at once; by propagating and checking deadlines so expired requests are dropped before any work; and, under overload, by considering adaptive limits and newest-first queueing.
What to remember
In this answer, we saw that Tomcat's large default connection queue let requests wait about 5.7 seconds for a thread while clients gave up after 2, so the server completed 1,400 requests per second for nobody. We separated throughput from goodput, bounded the queue with lower max-connections, a small accept-count and a concurrency limiter returning 503, dropped requests whose deadlines had passed, and used newest-first queueing under overload.
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 service is busy doing dead work: requests wait in Tomcat's connection queue for more than 2 seconds before a thread picks them up, so their clients have already given up, and throughput looks healthy while goodput, the useful completions, is near zero. Large queues turn a short overload into long waits for everyone. We fix it by bounding the waiting, with a much lower server.tomcat.max-connections than the default 8192, a small accept-count and a concurrency limiter that rejects excess with 503 at once; by propagating and checking deadlines so expired requests are dropped before any work; and, under overload, by considering adaptive limits and newest-first queueing.
Why this question is asked
This is one of the most confusing graphs an on-call engineer can see. The server is completing 1,400 requests per second, close to its normal 1,500, CPU is busy, nothing has crashed, and yet clients say almost every request fails. Interviewers ask it because the explanation, the difference between throughput and goodput, is the key idea behind every overload defence. In this answer, we will recap how Tomcat queues requests, work out how long requests wait, explain why the server's work is wasted, and then fix it by bounding the queue, checking deadlines, and choosing which requests to serve first.
1A Quick Recap of How Tomcat Queues Requests
Spring Boot's embedded Tomcat accepts connections up to server.tomcat.max-connections, which defaults to 8192. Each request needs a worker thread to run, and the pool is capped by server.tomcat.threads.max, 200 here. When all 200 threads are busy, accepted connections simply wait for one to become free. Beyond max-connections, the operating system holds up to server.tomcat.accept-count further connections, 100 by default, in its backlog.
So with default settings, Tomcat is willing to hold thousands of requests waiting for 200 threads. In normal times, that queue is empty and the setting does not matter. In overload, it decides how long everyone waits.
2Why Every Request Times Out
The service's real capacity is about 1,400 to 1,500 requests per second, limited by CPU and its dependencies rather than by thread count. Traffic arrives at 2,500 per second, so about 1,000 extra requests per second pile up. Within seconds the queue fills towards the 8,192 connection limit.
6 messages in order. Play them, or step through them one at a time.
Throughput counts this request; goodput does not.
Notice what this means. Every new request waits about 5.7 seconds before it even starts. Its client gave up after 2 seconds. So the server picks up a request whose caller is gone, does the full work, database calls and all, and writes a response to a closed connection. The server completes 1,400 requests per second and almost none of them reach anyone.
3Throughput Versus Goodput
Throughput is how many requests the server completes per second. Goodput is how many of those completions are useful, meaning the client is still waiting and receives the answer in time. In normal operation they are the same. In this overload, throughput is 1,400 and goodput is near zero.
Large queues cause this. While arrivals exceed the service rate, the queue grows, and the wait grows with it for every request, not just a few. A short overload of a few seconds becomes a long period in which every request waits too long. The fix is to keep the queue short enough that a waiting request still has time to be served.
4Fix 1: Bound the Waiting
We shrink the queue to what the service can drain within the client's budget. If the service serves 1,400 requests per second and we want a request to wait at most about 200 ms, the queue should hold roughly 1,400 x 0.2 = 280 requests beyond those being processed. So max-connections goes down from 8,192 to a few hundred, and accept-count stays small, so connections cannot pile up far beyond the 200 threads.
Connection limits alone are blunt: an over-limit connection waits in the OS backlog or is refused, which clients see as a connect timeout rather than a clear answer. So we add a concurrency limiter in the application, a filter that caps in-flight requests and rejects the excess immediately with 503 and Retry-After. Now overload means some clients get a fast rejection and retry later, while the accepted requests are served in time.
5Fix 2: Check Deadlines Before Doing Work
Even with a short queue, some requests will be close to their client's timeout by the time a thread picks them up. The client, or the gateway, can send its deadline in a header, and the load balancer can add the time it received the request. The service then checks before doing any work whether enough time remains to finish. If not, it drops the request at once instead of doing work nobody will receive.
The same check belongs before each call to a dependency. A request with 50 ms left should not start a 300 ms database query. Passing the remaining deadline downstream, for example in a header that each service reads and reduces, stops wasted work from spreading through the whole call graph.
6Fix 3: Serve the Newest Requests First Under Overload
A first-in, first-out queue serves the oldest request first, which in overload is the one most likely to have been abandoned. Under overload, serving the newest request first (LIFO) means we serve requests whose clients are still waiting, and the old ones time out in the queue, which is cheaper than serving them.
CoDel-style queueing, named after the controlled-delay algorithm used in networking, makes this adaptive: when the minimum queue time over a short interval stays above a target, the server switches to short queue timeouts and newest-first; when the queue drains, it goes back to normal. Combined with an adaptive concurrency limit, this keeps goodput high even when traffic far exceeds capacity.
7Follow-up questions
How would you choose the concurrency limit, and should it adapt automatically?
Start from Little's law: in-flight requests equal throughput times latency, so 1,500 requests per second at 40 ms means about 60 in flight on average. The limit should sit a bit above that, where load tests show latency starting to climb, perhaps 100 to 150. But capacity changes with dependency latency, deployments and hardware, so a fixed number is either too low on good days or too high on bad ones. An adaptive limiter that raises the limit while latency is stable and cuts it when latency rises, using AIMD or a gradient algorithm, tracks real capacity and is the better choice for a service that sees overloads.
Do virtual threads change this?
Virtual threads remove the thread limit, which makes it even easier to accept unbounded work. The bottleneck moves to CPU, connection pools and dependencies, so an explicit concurrency limit matters more, not less.
8Conclusion
In this answer, we saw that Tomcat's large default connection queue let requests wait about 5.7 seconds for a thread while clients gave up after 2, so the server completed 1,400 requests per second for nobody. We separated throughput from goodput, bounded the queue with lower max-connections, a small accept-count and a concurrency limiter returning 503, dropped requests whose deadlines had passed, and used newest-first queueing under overload.
Open with
The server is doing work for clients that have already left. The service can complete roughly 1,400 to 1,500 requests a second, but 2,500 are arriving, so about 1,000 a second pile up in Tomcat's queue.
Then, if they want more
By default, Tomcat accepts up to 8,192 connections for 200 threads, so the queue grows into the thousands. With about 8,000 waiting and 1,400 served per second, a new request waits roughly 5.7 seconds before a thread even picks it up, but the client gave up after 2 seconds and probably retried.
So throughput looks fine while goodput, the completions that actually reach a waiting client, is near zero. A large queue turns a short overload into long waits for everyone instead of a fast rejection for a few.
To fix it, I would bound the waiting: lower server.tomcat.max-connections to a few hundred, keep accept-count small, and add a concurrency limiter filter that rejects excess requests immediately with 503 and Retry-After.
Then I would propagate the client's deadline in a header and drop any request that does not have enough time left, before doing work and before each dependency call. Under heavy overload, serving newest requests first or CoDel-style queueing helps, because recent requests still have clients waiting.
And I would make the concurrency limit adaptive, so it follows real capacity rather than a fixed guess.
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 "The service now completes 1,400 requests per second, yet clients report that almost...": https://scrivio-interview-library.netlify.app/architecture/high-availability/88a2ee22aa/