Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

Your organization has 60 Java services on containers and teams want to move some to AWS Lambda. Several of them use PostgreSQL through Hibernate, and one handles steady 2,000 requests per second. How do you decide which services fit Lambda, and what platform rules do you set?

Lambda fits bursty, event-driven and low-traffic services; a service with steady traffic of 2,000 requests per second is usually cheaper and more predictable on the containers it already runs on. For the Hibernate services, the deciding problems are database connections, because every concurrent environment opens its own, and startup time, so we require RDS Proxy or one or two connections per environment and a cold start budget met with SnapStart, AOT or native images. We decide per service with a cost model on real traffic, including the cost of running a second platform, and back it with platform rules for templates, observability, timeouts, concurrency limits, retries and dead-letter queues.

Why this question is asked

When teams ask to move to Lambda, the request usually comes from real pain: idle containers that cost money, slow scaling, or patching servers. But Lambda changes the economics and the failure modes, and a few wrong moves, such as putting a steady high-traffic API on it or letting 500 environments open connections to one PostgreSQL instance, cost more than they save. Interviewers ask this design question to see whether we decide with numbers and set rules that keep 60 services safe. In this answer, we will recap what Lambda is good at, run a cost comparison for the 2,000 requests per second service, look at the database connection problem, set a startup budget, and write down the platform rules.

1What Lambda Is Good At

Lambda charges per request and per GB-second of execution, scales out by creating execution environments, and scales to zero when idle. That is ideal when traffic is spiky or rare: a webhook that fires a few hundred times an hour, a job triggered by S3 uploads, an SQS consumer whose queue fills up twice a day. We pay nothing between bursts and need no capacity planning.

It is weaker when traffic is high and flat. Then the environments never go idle, we pay a premium per unit of compute, and we inherit limits a container does not have: one request per environment at a time, a 15-minute maximum duration, cold starts, and per-account concurrency quotas. So the first filter is the traffic shape.

Step throughDoes this service fit Lambda?
  1. Traffic bursty, event-driven or low?
    YesContinueNoStay on containers
  2. Requests finish well under 15 minutes?
    YesContinueNoStay on containers
  3. Uses a relational database?
    YesRequire RDS Proxy or tiny poolsNoContinue
  4. Meets the cold start budget?
    YesContinueNoSnapStart, AOT or native first
  5. Cost model on real trafficincludes the second platform
  6. Cheaper or clearly simpler?
    YesMove with the standard templateNoStay on containers

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

Traffic shape is the first filter; cost decides the rest.

2Running the Numbers for 2,000 Requests per Second

Let us cost the steady service roughly, at list prices at the time of writing, which we would check before deciding. 2,000 requests per second for a 30-day month is about 5.2 billion requests. At 0.20 dollars per million, requests alone are about 1,040 dollars. If each takes 50 ms at 1 GB of memory, that is about 260 million GB-seconds, roughly 4,300 dollars at about 0.0000167 dollars per GB-second. So the function costs around 5,300 dollars a month.

Little's law tells us the same service needs only about 2,000 x 0.05 = 100 requests in flight at once. A Spring Boot container with 2 vCPU and 4 GB can typically handle 20 to 50 of those concurrently, so six to eight Fargate tasks with headroom would do it, at very roughly 75 dollars each per month, around 500 to 600 dollars. Even with generous error bars, the container is several times cheaper and its latency has no cold starts. That is why steady high traffic usually stays on containers.

Rough monthly cost for 2,000 requests per second
ItemLambdaContainers (Fargate)
Requestsabout 1,040 dollarsincluded
Computeabout 4,300 dollars (50 ms, 1 GB)about 500 to 600 dollars (6 to 8 tasks)
Cold startsyes, needs mitigationno
Second platform to operateyesno
List-price estimates; rerun the model with real durations and prices.

3The Database Connection Problem

Several services use PostgreSQL through Hibernate. On containers, each pod has a HikariCP pool, perhaps 10 connections, and 8 pods give 80 connections, a number the DBA planned for. On Lambda, each concurrent execution environment is its own JVM with its own pool. If a burst creates 300 environments and each keeps a default pool of 10, the database sees 3,000 connection attempts, far beyond a typical max_connections of a few hundred. Each PostgreSQL connection is a separate server process with its own memory, so the database falls over before Lambda even notices.

We set two rules. Functions that use a relational database go through RDS Proxy, which keeps a shared, bounded pool to the database and multiplexes many client connections onto it. And pools inside functions are 1 or 2 connections, because an environment handles one request at a time. We also cap the function's concurrency, so even a huge burst cannot open more connections than the proxy and the database can take.

4A Cold Start Budget

Hibernate and Spring Boot are reflection-heavy and can take several seconds to initialize. We do not forbid them, but every service that moves gets a cold start budget derived from its latency target, for example a 1.5-second maximum Init or Restore Duration for synchronous APIs and none for asynchronous consumers. Meeting the budget may require SnapStart with restore hooks, Spring AOT, a native image, or simply dropping Hibernate for plain JDBC in a small function. If none of that works, the service is not a fit yet.

5Platform Rules for Every Function

Sixty services moving piecemeal will each reinvent logging, retries and configuration, so the platform team publishes rules and a template. The template is a handler skeleton with structured JSON logs carrying the request id, tracing through X-Ray or OpenTelemetry, metrics, and the SDK clients set up in static fields. Every function declares a timeout shorter than its caller's timeout and a reserved or maximum concurrency. Asynchronous functions must have a dead-letter queue or an on-failure destination and idempotent handlers, because Lambda retries asynchronous events and SQS delivers at least once. And the cost model is part of the proposal: requests, duration and memory from real traffic, compared with containers, plus the engineering cost of a second runtime model, its deployment pipeline, its on-call knowledge and its tooling.

Step throughWhat the Lambda platform template provides
  1. Handler templatestatic clients, request id in every log line
  2. Observabilitystructured logs, traces, metrics
  3. Limitstimeout below caller, reserved or maximum concurrency
  4. Failure handlingretries, DLQ or on-failure destination, idempotency
  5. Data accessRDS Proxy, pools of 1 to 2 connections

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

6Follow-up questions

When does reserved concurrency protect a downstream system?

Reserved concurrency sets the maximum number of environments a function may run at once, and also guarantees that capacity from the account's pool. If a function's pool has 2 connections and its reserved concurrency is 50, it can never open more than 100 connections, however large the burst, so the database or a rate-limited partner API is protected. The extra requests are throttled: for synchronous calls the caller gets a 429 and must retry, and for SQS or asynchronous events Lambda retries later, so the work waits instead of overloading the dependency.

Which of the 60 services would you move first?

Event-driven consumers and scheduled jobs with low or spiky traffic, no relational database or a light one, and no strict synchronous latency target. They show the largest savings, the cold start barely matters, and they let the platform team prove its template and rules before any customer-facing API moves.

Does Lambda save operations work compared with containers?

It removes server and cluster management, but adds its own: concurrency quotas, cold start tuning, a different deployment and observability model, and limits such as the 15-minute duration. For a company already good at containers, running both is real ongoing cost, which is why we count it in the decision.

7Conclusion

In this answer, we saw that the fit for Lambda is decided first by traffic shape: bursty, event-driven and low-traffic services gain, while steady 2,000 requests per second costs several times more than containers. Relational databases need RDS Proxy, tiny pools and concurrency caps, Hibernate-heavy services need a cold start budget, and every function follows platform rules for templates, observability, timeouts, concurrency, retries and dead-letter queues. The decision is made per service with a cost model that includes running a second platform.

What to say in the interviewAbout 100 seconds aloud

Open with

I would decide service by service, starting with the traffic shape. Lambda is great for bursty, event-driven or low-traffic work because it scales to zero and needs no capacity planning.

Then, if they want more

For steady traffic it is expensive: 2,000 requests per second is about 5 billion requests a month, which at list prices is roughly a thousand dollars in request fees plus several thousand in compute, while the same load fits on a handful of Fargate tasks for a few hundred dollars, with no cold starts. So that service stays on containers.

For the Hibernate services, the main risk is connections. Each concurrent environment is a separate JVM with its own pool, so a burst of a few hundred environments can exhaust PostgreSQL. My rules are RDS Proxy in front of the database, pools of one or two connections per function, and reserved concurrency so the total is bounded.

The second risk is startup, so each synchronous function gets a cold start budget, met with SnapStart, AOT or native images, or by using plain JDBC. Every proposal includes a cost model from real traffic, plus the cost of operating a second runtime model.

Then the platform rules: a standard handler template, structured logs and tracing with X-Ray or OpenTelemetry, timeouts shorter than the caller's, concurrency limits, dead-letter queues and idempotent handlers for async work. I would start with event consumers and scheduled jobs, which save the most and risk the least.

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.
Official documentation
AWS documentation
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 organization has 60 Java services on containers and teams want to move some to AWS...": https://scrivio-interview-library.netlify.app/spring-boot/aws/bc6294a3be/