← Blog

Serverless · Capacity Planning · Reliability

What Happens When Serverless Compute Scales Faster Than the System Behind It?

Lambda can add capacity far faster than the databases, caches and third-party APIs behind it. This article covers how to work out how much concurrency the whole request path can take, and the limits, queues and tests that keep elastic compute from overwhelming everything else.

Aashaya Aryal

October 25, 2025 · 14 min read

Updated November 17, 2026

Rows of rack-mounted servers and network equipment inside a brightly lit data center.

One of the most attractive things about serverless is that you can stop thinking about servers. Traffic rises, the platform creates more execution environments, and capacity shrinks again when demand falls. You don't provision for peak, you manage much less infrastructure, and you pay more directly for what actually runs.

That's a real advantage, and it comes with a subtle trap: the compute layer can scale much faster than everything it depends on. AWS Lambda can add execution environments quickly as traffic rises, but the relational database behind it still has a fixed number of connections and a fixed query capacity. A third-party API may allow a set number of requests per second. Redis can look limitless until a hot key or a burst of cache misses changes the workload. A legacy service may be fine at 50 concurrent calls and fall over at 200.

I ran into this while building a serverless backend with API Gateway, Lambda, Redis, a database, payment integrations and asynchronous workflows. The question that mattered wasn't "can Lambda scale?" (it's designed to). It was "how much concurrency can the whole request path safely absorb?" Elastic compute isn't infinite capacity. It's a very effective way to remove one bottleneck, which then shows you the next one.

Serverless removes one limit, not all of them

Take a simple API:

Diagram

Users

API Gateway

AWS Lambda

Database

At 20 requests per second, each Lambda invocation queries the database and everything is comfortable. When traffic jumps to 2,000 requests per second, Lambda responds by adding concurrent execution environments. According to the Lambda scaling documentation, each function can add up to 1,000 execution environments every 10 seconds, up to the account's concurrency limit.

That's very useful, but Lambda's scaling isn't asking whether your database can take 1,000 new clients, or whether your payment provider can handle the request rate those workers will generate. Those decisions belong to your architecture. This is the core mismatch: the compute tier can grow faster than the dependencies needed to finish the work, so a system can get better at accepting work while getting worse at completing it.

Concurrency connects traffic to capacity

Requests per second alone don't tell you how many invocations run at once. A useful approximation (Little's law) is:

concurrency ≈ request rate × average duration

At 2,000 requests per second and 250 ms per invocation, that's about 2,000 × 0.25 = 500 concurrent executions. If the database is safe with about 200 concurrent application connections, and every execution environment opens its own connection, you have a mismatch before anything has even gone wrong:

Diagram

500 connection attempts

2,000 requests/sec

API Gateway

~500 concurrent Lambdas

Database
~200 safe connections

The Lambda tier is healthy; the database isn't.

The formula also shows why slow dependencies are dangerous. Duration is part of concurrency, so if the database slows down, invocations live longer and concurrency rises without any extra traffic. More overlapping invocations mean more simultaneous database work, which slows the database further. Elastic compute ends up amplifying the slowdown instead of hiding it.

Database connections

Relational database connections make the mismatch especially visible, because each connection uses memory and server resources. In a long-running service, connection counts are predictable: five instances with a pool of 20 connections each means about 100 connections. With Lambda, if each execution environment connects on its own, connection count starts following concurrency, and a platform that can create hundreds of environments quickly becomes a database-connection generator.

Diagram

Lambda 1

Lambda 2

Lambda 3

Lambda ...

Lambda 500

Relational Database

AWS's guide to using Lambda with Amazon RDS says direct connections are fine for simple cases and recommends RDS Proxy for production. The proxy keeps a shared pool of database connections, so the number of functions doesn't translate directly into the number of database connections:

Diagram

Lambda

Managed connection pool

Lambda

Lambda

Lambda

Lambda

RDS Proxy

RDS

That fixes connection pressure, not database throughput. If the database can sustain 5,000 queries a second, a proxy makes connections cheaper and better reused, but it won't make it 50,000. CPU, I/O, slow queries, lock and transaction contention, storage throughput and memory are all still there. The failure mode moves from "too many connections" to "database CPU at 100%". The system got better, and the bottleneck moved.

A related optimisation is creating clients outside the handler, so a warm execution environment reuses them. The Lambda best practices recommend initialising SDK clients and database connections outside the handler:

TS
import { MongoClient } from "mongodb";

const client = new MongoClient(process.env.MONGODB_URI!);

let connectionPromise: Promise<MongoClient> | undefined;

async function getClient() {
  connectionPromise ??= client.connect();
  return connectionPromise;
}

export async function handler() {
  const dbClient = await getClient();
  const db = dbClient.db("marketplace");

  return db.collection("orders").findOne({
    status: "pending",
  });
}

That's good practice, but one warm environment reusing one client doesn't mean 500 environments share one client. Reuse reduces churn and setup cost for each worker; it doesn't decide how many workers the dependency can tolerate.

The narrowest part of the path

Architecture diagrams show boxes: API Gateway, then Lambda, then the database. For capacity planning, I find it more useful to picture each box with its own scaling curve. API Gateway and Lambda scale very elastically. Database connections and throughput are finite. Redis has finite throughput and memory. A payment API is rate limited, and an email provider has a quota.

Diagram

API Gateway
High capacity

Lambda
Elastic

Redis
Finite

Database
Finite

External API
Rate limited

The capacity of a request path is set by the narrowest resource it needs, not the widest, and that differs by operation. A read-heavy endpoint may be limited by the cache, checkout by the payment provider's quota, a report by database I/O, and a background import by one legacy API. Once serverless removes the application server as the obvious ceiling, these limits become much more visible. That isn't a weakness of serverless; it's a reason to model the rest of the system explicitly.

Capping concurrency on purpose

Lambda's reserved concurrency is usually described as a way to stop one function from using all of an account's concurrency. It's also a bulkhead: a wall that protects a downstream system from the function. If load testing shows the database stays healthy up to 80 concurrent checkout operations and degrades fast after that, you can cap the function there:

YAML
Resources:
  CheckoutFunction:
    Type: AWS::Serverless::Function
    Properties:
      ReservedConcurrentExecutions: 80
      Handler: dist/handler.main
      Runtime: nodejs22.x

That can feel like a step backwards, since the point of serverless is to scale. But the real comparison often isn't "80 succeed versus 500 succeed". It's "80 succeed reliably versus 500 overload the database and almost nothing completes". AWS's post on understanding Lambda scaling and throughput discusses using reserved concurrency in exactly this way.

Here's why the limit can improve availability. Suppose the database is fine at 100 concurrent operations, starts queueing badly at 150 and is effectively unusable around 300. Without a cap, a traffic spike plays out like this:

Diagram

Traffic Spike

Lambda Scales

300 Concurrent DB Operations

Database Latency Increases

Lambda Duration Increases

Even More Lambda Concurrency Required

Database Collapses

The first step, Lambda scaling, works perfectly, which is why the loop is easy to miss. From then on, the system doesn't need more compute; it needs less pressure on the constrained resource. Throttling and concurrency limits aren't automatically anti-scalability. Often they're what lets the rest of the system stay up.

Queues turn bursts into backlogs

For asynchronous work there's another option: don't force arrival rate and processing rate to match. If one event creates 100,000 tasks and Lambda processes them straight away, the compute tier exposes as much parallelism as it can to a database that might only handle 40 concurrent workers. A queue separates producing work from consuming it:

Diagram

Controlled consumption

Producer

SQS

Lambda Workers

Database

Now the queue absorbs the difference between how fast work arrives and how fast the dependency can safely handle it. The producer stays elastic without every downstream system having to match.

A queue doesn't make the dependency faster, though. If 100,000 messages arrive and you can process 100 per second, SQS turns immediate overload into durable waiting. That's usually a much healthier failure mode, but it changes what you watch: the age of the oldest message can tell you more than Lambda's error rate. You've traded uncontrolled overload for controlled latency.

A queue also only creates backpressure if the consumer is limited. Lambda scales SQS consumers automatically, which is great until 10,000 queued messages produce more workers than the dependency can take. That's why event source mappings support a maximum concurrency setting for SQS, which you can set in SAM:

YAML
Resources:
  WorkerFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: dist/worker.handler
      Runtime: nodejs22.x
      Events:
        Jobs:
          Type: SQS
          Properties:
            Queue: !GetAtt JobsQueue.Arn
            BatchSize: 10
            ScalingConfig:
              MaximumConcurrency: 40

This writes down a capacity assumption: there may be a million messages waiting, but this queue never runs more than 40 workers at once. Queue depth tells you how much work exists, not how much should run concurrently.

When the backlog grows, it's tempting to raise worker concurrency to clear it faster. That only works until the dependency saturates. Say 40 workers complete 4,000 jobs a minute. At 200 workers, lock contention, I/O pressure and transaction conflicts might drop throughput to 2,500 a minute while latency soars. More concurrency helps while there's spare parallel capacity; past the limiting resource, it mostly creates queueing and contention. The fastest way to drain a queue is usually the concurrency at which the whole pipeline sustains its highest throughput, and that's something to load test rather than infer from how far Lambda can scale.

Limiting synchronous traffic at the edge

User-facing synchronous APIs can't always be queued, but they still need a way to stop external demand turning into unlimited internal demand. API Gateway supports request throttling with a rate and a burst limit:

Diagram

Accepted

429

Clients

API Gateway
Rate Limit

Lambda

Database

Rejected Early

AWS notes that these throttles are applied on a best-effort basis and should be treated as targets, not guaranteed ceilings. The broader point still holds: rejecting excess work at the edge is often healthier than accepting it, starting an invocation, opening database work, calling other services and then failing. A fast 429 is often more useful than a slow 500.

Third-party APIs and caches

Databases are easy to think about because you operate them. External dependencies are easier to forget. If each checkout calls a payment API, an email API, a fraud API and a shipping API, your application might support 1,000 concurrent checkouts while the shipping provider allows 100 requests per second. A traffic spike can then turn your serverless backend into an accidental denial-of-service attack on your partner. Their limit belongs in your design even though their infrastructure doesn't. Rate limiting, queues, batching, backoff, circuit breakers and reserved concurrency all help, depending on whether the call has to be synchronous. The real capacity question isn't how many functions can run, but how much work every required dependency can sustain while meeting its latency and reliability targets.

Caches have their own version of this. A cache protects a slower system:

Diagram

miss

Lambda

Redis

Database

With a 95% hit rate, the database sees only 5% of reads. If Redis becomes unavailable or the cache is flushed, the hit rate drops to zero and the database suddenly gets twenty times its normal read load. The Amazon Builders' Library article on caching challenges and strategies describes this: a cold or unavailable cache can send a surge of traffic to downstream services and cause outages. With serverless, the compute layer keeps scaling happily throughout. Lambda will scale straight into a cache-miss storm unless something else limits the work, so it's worth asking what happens when the hit rate goes to zero, not just how fast things are when the cache is warm.

Backpressure and who sets the pace

Many architecture diagrams quietly assume that every arrow means "receive work, send it straight on". A more resilient design asks at each arrow: can the next component safely accept this work right now? That's backpressure. In synchronous paths it shows up as 429 and 503 responses, reserved concurrency, rate limiting and load shedding. In asynchronous paths it shows up as durable queues, consumer concurrency, batch size and visibility timeouts. Without it, the fastest-scaling component pushes failure into the slowest-scaling one, and Lambda is deliberately very good at scaling fast.

The Builders' Library has a good name for the fix: putting the smaller service in control. If one system can produce work at huge scale and another can consume only a fraction of it, letting the bigger one set the pace is dangerous. A queue inverts that relationship:

Diagram

Produce quickly

Consume at safe rate

Highly Elastic Producer

Durable Queue

Capacity-Limited Consumer

The producer stays elastic and the consumer controls consumption. Not every component has to be equally elastic; the boundaries between differently sized systems just have to be deliberate.

It's also tempting to assume that if a dependency gets overloaded, autoscaling will catch up. Sometimes it does, but autoscaling is reactive: metrics are collected, a threshold is crossed, a decision is made, capacity is provisioned, and only then does it start helping. A burst can arrive much faster than that. Lambda scales unusually fast because AWS already runs the underlying fleet; your database, legacy service or third-party provider probably doesn't. Autoscaling is useful, but it shouldn't be the only protection between elastic demand and a slower-moving resource.

Observing the whole path

A healthy Lambda dashboard doesn't mean a healthy application. Lambda can report low errors and zero throttles while the database sits at 98% of its connections and 94% CPU with rising query latency. The compute tier looks fine precisely because the database is absorbing the damage. So I want visibility across the whole path:

LayerWhat to watch
LambdaConcurrent executions, duration, invocations, errors, throttles
API GatewayRequest rate, 4xx, 5xx, latency, integration latency
DatabaseActive connections, CPU, query latency, lock waits, I/O, slow queries
QueueMessages available and in flight, age of oldest message, dead-letter count
RedisLatency, connections, memory, evictions, hit rate
External dependencies429 rate, 5xx rate, latency, timeouts

The useful question isn't whether Lambda is healthy, but whether the whole workload is staying inside every dependency's safe operating range. That means correlating layers. Lambda duration rising together with database query latency explains a concurrency increase with no traffic change. A cache hit rate collapse alongside a database CPU spike suggests the cache was where the incident started. A growing oldest-message age with low error rates means the system is working but falling behind.

Finding the knee of the curve

A load test that only asks "at what traffic does it crash?" finds the cliff. A better test raises load gradually (50, 100, 200, 400, 800 requests per second and so on) while tracking throughput, p50/p95/p99 latency, database connections and CPU, Lambda concurrency and errors. What you're looking for is the knee of the curve: the point where adding concurrency stops adding much throughput and starts adding mostly latency.

ConcurrencyThroughputp99 latency
201,900/min180 ms
403,700/min210 ms
605,200/min280 ms
806,100/min450 ms
1006,200/min1.4 s
1505,500/min4.8 s

Throughput peaks around 100, but a better operating target is probably 60–80, where latency is stable and there's headroom for normal variation. The goal is sustainable throughput, not using every last resource. Testing the whole path also tells you where to put the limits. If going from 80 to 120 concurrent Lambdas adds almost no throughput while database latency triples, that's far more useful to know than "Lambda can handle 120 workers". You've found where downstream saturation begins.

Without that knowledge, a flash sale can look like this: traffic jumps, API Gateway accepts it, Lambda scales, CloudWatch shows rising invocations, and from the platform's point of view autoscaling worked. Then database connections run out, queries slow, invocations live longer, concurrency rises, clients time out and retry, and the database gets even more overlapping work.

Diagram

Traffic Spike

Lambda Scales Successfully

Downstream Saturates

Latency Increases

Lambda Invocations Live Longer

Concurrency Increases

Clients Retry

More Downstream Load

The system showed impressive elasticity while becoming less available. "Did autoscaling work?" isn't the reliability question. Autoscaling only helps if the work it creates can actually finish.

Putting it together

For a serverless backend with constrained dependencies, my starting architecture looks roughly like this:

Diagram

Slow / deferrable work

Clients

API Gateway
Rate + burst controls

Lambda API
Reserved concurrency

Redis

Database Proxy / Managed Pool

Database

SQS

Async Lambda Workers
Maximum concurrency

External APIs

The specific AWS services matter less than the boundaries they represent. Each important dependency should have a known safe number, such as 100 concurrent database operations, 200 requests per second to the payment provider, or 20 concurrent report jobs. That isn't the theoretical maximum, but where you actually want production to sit. Then the architecture should write those numbers down in configuration: reserved concurrency on synchronous functions, maximum concurrency on queue consumers, throttling at the edge, a connection pool or proxy in front of the database, and queues for anything that doesn't need to finish immediately. Capacity assumptions belong in infrastructure, not just in someone's head.

Key takeaways

  • Estimate concurrency as request rate × duration, and remember that slower dependencies raise concurrency without any extra traffic.
  • Know the safe concurrency or request rate for each dependency, and encode it with reserved concurrency, SQS maximum concurrency and edge throttling.
  • Use a connection pool or RDS Proxy for relational databases, but don't mistake it for more database throughput.
  • Queue deferrable work so bursts become backlogs, and watch the age of the oldest message.
  • Plan for a zero cache hit rate and for third-party rate limits. They're part of your capacity even if you don't run them.
  • Load test the whole path to find the knee of the curve, and operate below it.

References