System Design Playbook
18 · Async & cloud8 min read

What is AWS Lambda? Pros, cons and its two hard limits

Serverless functions that run your code on demand and scale automatically. How they work, what they are great at, and the two problems that decide whether a job can run on Lambda at all: memory and maximum execution time.

In one sentence

AWS Lambda runs a function only when an event arrives, scales to many copies by itself and bills per millisecond, but each run is capped at 10 GB of memory and 15 minutes.

What Lambda is

You upload a function, choose how much memory it gets, and connect it to triggers: an HTTP request (via API Gateway or a function URL), a file uploaded to S3, a message in SQS, a schedule. AWS starts an execution environment when needed, runs the code and later freezes or discards it.

  • No servers to manage: no OS patches, no capacity planning.
  • Automatic scaling: 1 request or 1,000 at the same time, each gets its own environment (up to your account's concurrency limit).
  • Pay per use: billed per request and per GB-second of execution. Idle costs nothing.

The two hard limits: memory and time

These two limits are what you check first when deciding if a job fits Lambda. Try the three jobs below with different memory and timeout settings.

Invoking a Lambda function
Job
Resize an image · needs ~300 MB · ~4.1 shard limit: 15 min · 10 GBMemory: 512 MBTimeout 30.0 s0 s30.9 s
Start
—
Duration
…
Billed (GB-s)
…
Status
—
CPU grows with the memory you assign, so more memory can also mean faster. But two hard limits never move: a function can't use more than 10 GB of memory and can't run longer than 15 minutes. Long or heavy jobs belong elsewhere (containers, AWS Batch, Step Functions to split the work).
Durations are illustrative. CPU scales with memory: around 1,769 MB a function gets the equivalent of one full vCPU.
LimitValueWhat happens when you hit it
Memory128 MB to 10,240 MB (10 GB)The runtime is killed with an out-of-memory error
Max execution time (timeout)Up to 900 s (15 minutes); default 3 sThe run is stopped: "Task timed out". Work in progress is lost

Ways around them: split the job into steps (Step Functions), process files in chunks, or move heavy and long jobs to containers (ECS/Fargate), AWS Batch or a regular server.

Cold starts

When no warm environment is available, Lambda has to create one: download the code, start the runtime and run your initialization. That cold start adds from tens of milliseconds to a few seconds, depending on the runtime and package size. Later requests reuse the warm environment.

  • Keep packages small and initialization light
  • Use provisioned concurrency (pre-warmed environments) for latency-sensitive APIs
  • Use SnapStart where supported (Java, Python, .NET) to restore from a snapshot

Pros and cons

Pros

  • Zero infrastructure to run
  • Scales from zero to thousands of parallel runs
  • Cheap for spiky or low traffic
  • Native triggers from S3, SQS, SNS, DynamoDB, EventBridge

Cons

  • Max 15 minutes and 10 GB per run
  • Cold starts add latency
  • No local state between runs: use S3, a database or a cache
  • Can be more expensive than a server at constant high traffic
  • Many functions can overwhelm a database with connections (use a proxy like RDS Proxy)
Great forThink twice for
Image thumbnails after an S3 uploadVideo transcoding or ML training jobs
Processing messages from a queueWebSocket servers holding long connections
Webhooks, cron jobs, glue between servicesVery high, constant traffic on one endpoint

Key takeaways

  • 01Lambda runs code per event, scales automatically and charges only for execution time.
  • 02Two hard limits decide if a job fits: 10 GB of memory and 15 minutes per invocation.
  • 03More memory also means more CPU, which can make functions faster and not much more expensive.
  • 04Cold starts, stateless runs and database connections are the practical gotchas.

Check your understanding

1 of 3

How do you pay for AWS Lambda?

Related concepts