Opscraft
Serverless with AWS Lambda · Lesson 3 of 6 · 5 min read

Scaling, limits and cold starts

Limits you must know

Limit Value Adjustable?
Timeout Up to 900 s (15 min) No
Memory 128 MB to 10,240 MB — (CPU scales with memory)
/tmp storage 512 MB to 10,240 MB —
Deployment package 50 MB zipped direct upload, 250 MB unzipped including layers No
Container image 10 GB No
Layers 5 per function No
Synchronous payload 6 MB request and response No
Asynchronous payload 1 MB No
Concurrent executions 1,000 per region by default Yes, by quota request

Memory is also the CPU dial: Lambda allocates CPU in proportion to memory, reaching a full vCPU at 1,769 MB and up to 6 vCPUs at 10 GB. A CPU-bound function often gets cheaper with more memory because it finishes faster. Tools like AWS Lambda Power Tuning measure the sweet spot.

Enlarge diagram512 MB2400 ms1,024 MB1150 ms1,769 MB (1 vCPU)640 msIllustrative: cost = memory × time, so 2× memory at half the time costs the same, and less if faster still.
Figure 1. Memory is the CPU dial. A CPU-bound function often costs less with more memory because it finishes sooner.
Swipe sideways to see all of it, or tap to open it full screen.

Running on arm64 (Graviton) is about 20% cheaper per GB-second than x86 and usually as fast or faster for interpreted runtimes.

Concurrency

Concurrency is the number of requests being handled at the same moment. Roughly: concurrency = requests per second × average duration in seconds. 200 requests per second at 0.5 s each needs about 100 concurrent environments.

Enlarge diagramACCOUNT POOL: 1,000 CONCURRENT EXECUTIONS PER REGIONpaymentsreserved 200: guaranteedand cappedthumbnailsreserved 50: protects the DBeverything elseshares the other 750200 req/s × 0.5 s = about 100 environments busy at once.
Figure 2. Concurrency ≈ requests per second × duration. Every function shares the regional pool unless you reserve a slice.
Swipe sideways to see all of it, or tap to open it full screen.
  • The account concurrency quota (1,000 by default) is shared by every function in the region. One runaway function can starve the others.
  • Reserved concurrency guarantees a function a slice of the pool and caps it at that number. Use it to protect critical functions and to stop a function overwhelming a downstream database. Reserved concurrency of 0 disables a function (a quick kill switch).
  • Provisioned concurrency keeps a number of environments initialised and warm, removing cold starts for that capacity, at an hourly cost. Schedule it with Application Auto Scaling for business hours.
  • Each function can scale up by 1,000 concurrent executions every 10 seconds.
  • Beyond the limit, synchronous calls get 429 TooManyRequestsException (throttled); async events are retried by Lambda's internal queue; polling sources slow down.

Cold starts

A cold start adds the init time: from under 100 ms for a small Python or Node.js function to several seconds for a large Java or .NET app. How to reduce it:

  • Smaller packages and fewer dependencies; lazy-load rarely used modules; avoid huge SDK bundles (bundle and tree-shake with esbuild).
  • Do expensive setup once outside the handler, but keep it lean.
  • SnapStart (Java, Python and .NET) snapshots the initialised environment when you publish a version and resumes from it, cutting cold starts dramatically. Make sure anything unique (random seeds, connections) is re-created after restore.
  • Provisioned concurrency for latency-critical paths.
  • Prefer interpreted or compiled-native runtimes (Node.js, Python, Go, Rust) for latency-sensitive functions.

Running a function in a VPC no longer adds a large cold-start penalty (the network interfaces are shared and created when the function is configured), but it does mean the function needs a NAT gateway or VPC endpoints to reach AWS APIs and the internet.