Scrivio Interview library
LeadershipAdvanced8 min read · updated 12 November 2026

Across your organisation, services set pool sizes by copying values from other services, and several incidents were caused by too many database connections. What standard would you introduce?

I would make pool sizes a deliberate, reviewed decision instead of a copied number. The platform starter ships sensible defaults with the reasoning written down, every override is explicit in configuration, each shared database has a connection budget that adds up pods times pool size across all its clients, pool saturation is on the standard dashboard with alerts, and critical services prove their settings with a load test.

Why this question is asked

Copying a pool size from a neighbouring service feels harmless, because the number worked over there. The trouble is that a pool size is not a property of one service: it multiplies by the number of pods, and every service that shares a database draws from the same limited supply of connections. Interviewers ask this question at senior level to see whether we can turn a recurring incident into a standard that teams follow without a central team doing their work for them. In this answer, we will recap why copied pool sizes cause incidents, then build the standard piece by piece: defaults in the starter, a connection budget per database, saturation metrics, design reviews and load tests, and finally how to roll it out.

1A Quick Recap: Why Copied Pool Sizes Hurt

A connection pool, such as HikariCP, the default in Spring Boot, keeps a set of open database connections so that each request can borrow one instead of opening a new connection, which costs several milliseconds and work on the database. The setting that matters here is the maximum pool size: the most connections one application instance may hold at once.

The database has its own limit. PostgreSQL, for example, has max_connections, which is 100 by default, and every connection is a backend process with its own memory. Long before the hard limit, many active connections compete for the same CPU cores and disks, so more connections can make every query slower.

Now picture the incident. One team copies maximum-pool-size 50 from a busy service. Their service runs 12 pods, so it can open 600 connections. During a deployment, old and new pods run side by side and the number briefly doubles. The database refuses new connections, and every service that shares it fails at the same moment, including the ones that did nothing wrong.

Properties
# What the copied setting really means
spring.datasource.hikari.maximum-pool-size=50 # per pod
# pods: 12 -> 12 x 50 = 600 possible connections
# rolling deploy with 25% surge: 15 pods -> 750
# database max_connections: 400, shared with 5 other services

2Defaults With Reasons in the Platform Starter

The first part of the standard removes the need to copy. Most organisations have a platform starter, a shared Spring Boot dependency that every service includes to get logging, metrics and security set up the same way. We put a small, safe pool default in it and write down why it was chosen.

A good default is small, for example 10 connections, which is also HikariCP's own default. The reason is that a pool only needs as many connections as there are queries running at the same moment, and a well-behaved request holds a connection for a few milliseconds. Ten connections that each serve a 5 ms query can serve about 2,000 queries per second per pod.

Properties
# platform-starter: application-platform.properties (loaded as a low-priority default)
# Default pool: 10 connections per pod. Reason: 10 x (1000 ms / 5 ms per query) = 2,000 queries/s.
# Override only with a reason and a connection budget entry for your database.
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.connection-timeout=2000 # fail fast after 2 s instead of the 30 s default
spring.datasource.hikari.max-lifetime=1800000

Overrides stay allowed, because some services really do need more, but they must be explicit: the value lives in the service's own configuration with a comment or a link to the budget entry that justifies it. A reviewer who sees a pool size change can then ask the right question, which is how the new total fits the database, not whether 50 looks like a reasonable number.

3A Connection Budget per Shared Database

The heart of the standard is the connection budget. For each shared database we keep one small file, owned by the team that owns the database, listing every client and the connections it may open. The arithmetic is simple: maximum pods times pool size, including the surge during deployments and autoscaling to its maximum replica count.

The budget must stay below what the database can serve well, not below its hard limit. We usually keep a reserve for administrators, migrations and monitoring tools, and we sum the worst case rather than the average, because incidents happen at the worst case.

Connection budget for the orders database (max_connections 400)
ClientMax pods (with surge)Pool sizeWorst case
order-service1510150
payment-service81080
reporting-batch22040
admin and migrations--30 reserved
Total300 of 400 (75%)
Every pool change updates this file; the total must stay under the agreed ceiling.

Notice that the budget changes the conversation between teams. When a team wants to double its pool, the file shows whether there is room, and if not, someone has to give connections back or the database needs a connection proxy. We can enforce it cheaply with a CI check that reads each service's pool size and maximum replica count from its deployment configuration and fails the build if the total for any database passes the ceiling.

4Saturation Metrics and Alerts on the Standard Dashboard

A budget tells us what services may do; metrics tell us what they actually do. Spring Boot with Micrometer already exports HikariCP metrics, so the platform only has to put them on the standard service dashboard that every team gets.

The useful ones are active connections against the maximum, pending threads waiting for a connection, and the time it takes to acquire one. A pool that is always at its maximum with threads waiting is saturated: the service is queueing for connections, usually because queries or transactions are too slow, not because the pool is too small. On the database side we chart total connections against the budget ceiling.

Java
hikaricp_connections_active{pool="HikariPool-1"} # 10 (max 10: saturated)
hikaricp_connections_pending{pool="HikariPool-1"} # 37 threads waiting
hikaricp_connections_acquire_seconds_max # 1.8 s to get a connection
# Standard alerts: pending > 0 for 5 minutes; database connections > 80% of ceiling

The alerts are part of the standard too, with sensible thresholds that teams can tighten. The point is that the first sign of trouble should be a warning on a dashboard, not a database refusing connections.

5Design Reviews and Load Tests

Two moments change connection use the most: a new service joining a shared database, and a scaling change such as raising the maximum replicas from 10 to 40. We add pool settings and the budget entry to the design review checklist for both, so the question is asked before the change ships. It is one line in a checklist, not a new committee.

For critical services we also ask for evidence. A load test at expected peak shows whether the pool size is enough, whether threads wait for connections, and how the database behaves with all pods running. That evidence is what turns a pool size from a guess into a decision.

6Rolling the Standard Out So Teams Follow It

A standard that arrives as a document is ignored; a standard that arrives as working defaults and a failing check is followed. So we roll it out in that order: ship the starter defaults first, publish the budgets for the two or three databases that caused incidents, add the dashboard panels, and only then turn the CI check from warning to failure.

We also explain the reason with the incidents themselves. Showing teams the arithmetic of the last outage, 750 possible connections against a limit of 400, convinces people faster than any rule.

Step throughChanging a pool size under the standard
  1. Team proposes a new pool sizewith the reason, such as measured pending threads
  2. Update the database's budget filepods with surge x pool size
  3. Total under the ceiling?
    YesMerge; CI check passesNoGive connections back or add a proxy
  4. Watch saturation on the dashboardactive, pending, acquire time
  5. Load test critical servicesconfirm at peak

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

7Follow-up questions

Why not simply raise max_connections on the database?

Because connections are not free. In PostgreSQL each connection is a process with its own memory, and many active connections compete for the same CPU and disks, so throughput often falls once active connections far exceed the number of cores. Raising the limit hides the budgeting problem until the next growth step, and then the failure is slower and harder to diagnose.

How do you choose a pool size for a single service?

Start from the queries in flight, not from request threads. If a pod handles 200 requests per second and each holds a connection for 10 ms, it needs about 2 connections on average, so 10 leaves plenty of headroom. Then confirm with a load test and the pending-threads metric. If the pool is saturated, look first for slow queries or long transactions before adding connections.

What about services that use virtual threads?

Virtual threads make it cheap to have thousands of concurrent requests, which means far more threads can ask for a connection at once. The pool then becomes the limit that protects the database, so the budget matters even more. Keep the pool small and let requests wait briefly for a connection rather than letting every virtual thread hit the database.

8Conclusion

In this answer, we saw that copied pool sizes cause incidents because a pool size multiplies by pods and shares one database's limited capacity. The standard ships small defaults with reasons in the platform starter, makes overrides explicit, keeps a connection budget per shared database that sums pods times pool size, puts saturation metrics and alerts on every dashboard, adds pool settings to design reviews and checks critical services with load tests. Rolling it out as working defaults and automated checks, explained with real incidents, is what makes teams follow it.

What to say in the interviewAbout 80 seconds aloud

Open with

I would treat pool sizes as a shared resource rather than a local setting. First, the platform starter ships a small default, ten connections, with the reasoning written next to it, and any override has to be explicit in the service's configuration with a reason.

Then, if they want more

Second, every shared database gets a connection budget owned by the database team: it lists each client and sums maximum pods, including deployment surge, times pool size, and the total has to stay under a ceiling below max_connections with a reserve for admin work. A CI check can enforce that.

Third, HikariCP metrics, active, pending and acquire time, go on the standard dashboard with alerts, so saturation shows up as a warning and not as an outage. Fourth, pool settings and the budget entry are part of the design review for new services and for scaling changes.

And for critical services I would ask for a load test at peak to confirm the numbers. I would roll it out by shipping the defaults and dashboards first, then turning the check from warning to failure, and I would explain it using the arithmetic from our own incidents, because that convinces teams faster than a policy document.

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 "Across your organisation, services set pool sizes by copying values from other services...": https://scrivio-interview-library.netlify.app/spring-boot/service-performance/843b72825d/