Quick revision
The short answer
In Spring Boot, Tomcat allows at most 200 request threads by default (server.tomcat.threads.max) and HikariCP's maximumPoolSize defaults to 10. When all 10 connections are in use, a thread that needs one waits up to connectionTimeout, 30 seconds by default, and then gets an SQLTransientConnectionException. With 200 threads sharing 10 connections, threads queue for connections under load, which is fine when transactions are short, and we watch hikaricp.connections.active, pending and the acquire time to see when it is not.
What to remember
In this answer, we saw that Spring Boot's embedded Tomcat allows 200 request threads and HikariCP 10 connections by default. When all connections are in use, threads wait up to connectionTimeout, 30 seconds by default, then fail with SQLTransientConnectionException, usually wrapped by Spring. Two hundred threads sharing ten connections works when transactions are short, and hikaricp.connections.active, pending and acquire time tell us when it stops working.
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.
In Spring Boot, Tomcat allows at most 200 request threads by default (server.tomcat.threads.max) and HikariCP's maximumPoolSize defaults to 10. When all 10 connections are in use, a thread that needs one waits up to connectionTimeout, 30 seconds by default, and then gets an SQLTransientConnectionException. With 200 threads sharing 10 connections, threads queue for connections under load, which is fine when transactions are short, and we watch hikaricp.connections.active, pending and the acquire time to see when it is not.
Why this question is asked
These two numbers sit at the center of almost every Spring Boot performance problem, and many developers have never looked them up. Knowing them, and what happens when the smaller one runs out, explains a lot of production behaviour, from sudden 30-second hangs to errors under load. Interviewers ask this to check basic operational knowledge before going deeper. In this answer, we will recap what each pool does, look at the defaults, walk through what happens when all connections are busy, see why 200 threads and 10 connections usually work together, and set up the metrics that tell us when they do not.
1A Quick Recap of the Two Pools
A Spring MVC application on embedded Tomcat handles each HTTP request on a thread from Tomcat's request thread pool. The thread runs our controller, service and repository code and is busy until the response is written. The pool's maximum size is how many requests the service can work on at the same time.
A database connection is expensive to open, often several milliseconds with TLS and authentication, so Spring Boot uses HikariCP, a connection pool that keeps open connections and lends them to threads. A thread borrows a connection when a transaction or query starts and returns it when it ends. The pool's maximum size is how many database operations can run at the same time.
2The Defaults and Where They Come From
Both defaults can be changed in application.yml. These are the values when we set nothing.
| Setting | Default | Meaning |
|---|---|---|
server.tomcat.threads.max | 200 | requests processed concurrently |
server.tomcat.accept-count | 100 | queued connections when threads are busy |
spring.datasource.hikari.maximum-pool-size | 10 | concurrent database operations |
spring.datasource.hikari.connection-timeout | 30000 ms | wait before giving up on a connection |
spring.datasource.hikari.max-lifetime | 1800000 ms | connection replaced after 30 min |
Notice the ratio: 200 threads can ask for connections, but only 10 exist. That is intentional, not a mistake, as we will see.
3What Happens When All Connections Are in Use
Suppose all 10 connections are lent out and an eleventh thread needs one. Hikari does not fail immediately. The thread waits, parked, for a connection to be returned. If one comes back within connectionTimeout, the thread takes it and continues, a little later than it would have. If none comes back within 30 seconds, Hikari throws SQLTransientConnectionException with a message saying the connection is not available and the request timed out after 30000 ms, often with the counts of total, active, idle and waiting connections. Spring usually wraps it, for example in a CannotCreateTransactionException when a @Transactional method starts, so check the cause chain in your stack trace.
5 messages in order. Play them, or step through them one at a time.
If nothing is returned within connectionTimeout, thread 11 gets an exception instead.
The 30-second default is worth thinking about. A user-facing request that waits 30 seconds for a connection has long been abandoned by its caller, and meanwhile the waiting thread is held. Many teams lower connectionTimeout to a few seconds, so the service fails fast and sheds load instead of piling up waiting threads.
4Why 200 Threads and 10 Connections Usually Work
A request spends only part of its time in the database. It also parses JSON, runs business logic, calls other services and writes the response. If a request takes 100 ms and holds a connection for 10 ms of it, 10 connections can serve 10 / 0.010 = 1,000 database operations per second, while 200 threads can serve 200 / 0.1 = 2,000 requests per second. Under load, threads queue briefly for connections, a few milliseconds, which is harmless.
The trouble starts when transactions are long. If each request holds its connection for 100 ms, for example because the transaction includes a remote call or because open-in-view keeps the session until the response is written, the pool's capacity drops to 100 requests per second, and threads start waiting for seconds. So the default works as long as transactions are short, and the cure for waiting is usually to shorten them rather than to enlarge the pool.
5Watching the Pool With Metrics
Spring Boot registers HikariCP metrics with Micrometer automatically. Three tell us everything about connection pressure: hikaricp.connections.active, how many connections are lent out right now; hikaricp.connections.pending, how many threads are waiting for one; and hikaricp.connections.acquire, a timer of how long threads waited. Healthy services show active below the maximum most of the time, pending near zero, and acquire times of a millisecond or less. Pending above zero for long periods, or acquire times in the hundreds of milliseconds, mean the pool is the bottleneck. hikaricp.connections.timeout counts the timeouts that became exceptions.
6Follow-up questions
Should we just set maximumPoolSize to 200 to match the threads?
Usually not. The database has limited CPU and disk, and running 200 queries at once from each instance overloads it, increasing the time each query takes, so total throughput often drops. A small pool with short waits makes better use of the database. If metrics show long waits, we first find out why connections are held so long; we raise the pool only if the database has spare capacity, and we count all instances against its max_connections.
What happens when all 200 Tomcat threads are busy?
New connections are accepted up to max-connections, and their requests wait in the accept queue, up to accept-count, for a free thread. Beyond that, the operating system refuses connections, and clients see connection errors. Busy threads at the maximum is a saturation signal, like pending connections for the pool.
Does minimum-idle matter?
By default it equals the maximum, making the pool fixed-size, which HikariCP recommends for predictable performance. A lower minimum-idle can save connections on a database shared by many services, at the cost of opening connections during bursts.
7Conclusion
In this answer, we saw that Spring Boot's embedded Tomcat allows 200 request threads and HikariCP 10 connections by default. When all connections are in use, threads wait up to connectionTimeout, 30 seconds by default, then fail with SQLTransientConnectionException, usually wrapped by Spring. Two hundred threads sharing ten connections works when transactions are short, and hikaricp.connections.active, pending and acquire time tell us when it stops working.
Open with
Tomcat's maximum request threads default to 200, set with server.tomcat.threads.max, and HikariCP's maximumPoolSize defaults to 10, with minimum idle equal to it, so it is a fixed pool of 10.
Then, if they want more
When all 10 connections are lent out, the next thread that needs one does not fail right away. It waits, for up to connectionTimeout, which is 30 seconds by default. If a connection is returned in that time, the thread takes it and the request is just slower.
If not, Hikari throws SQLTransientConnectionException saying the connection is not available and the request timed out after 30000 milliseconds, and Spring usually wraps that, for example in CannotCreateTransactionException. Having 200 threads and only 10 connections sounds unbalanced, but it is normal, because a request spends only a small part of its time holding a connection.
If it holds one for 10 milliseconds, 10 connections handle about a thousand operations per second, and under load threads queue for a few milliseconds. It breaks when transactions are long, for example a remote call inside a transaction, or open-in-view holding the connection until the response is written. Then threads wait for seconds and eventually time out.
I often lower connectionTimeout to a few seconds so the service fails fast. To see where we are, I watch hikaricp.connections.active against the maximum, hikaricp.connections.pending, which should be near zero, and the acquire timer. If pending stays up, I look for long transactions before I think about raising the pool size.
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 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 "What are the default Tomcat request thread limit and HikariCP pool size in Spring Boot...": https://scrivio-interview-library.netlify.app/spring-boot/service-performance/621480f578/