
What AWS Lambda Really Costs, Really Weighs, and Really Can't Do
Lambda is the first service every builder learns — and the last one they fully understand. The real cost math, every hard limit, and the seven gotchas tutorials skip.
AWS Lambda, Decoded: The Numbers, Costs, and Gotchas That Tutorials Skip
If you followed my Free Tier survival guide, you already met Lambda once: the "$20 activity" where you build a small web app with a function URL. That's usually the first encounter — and for a lot of builders, it's also where the misconceptions start.
Lambda is the service AWS beginners love and then quietly mistrust, because it behaves like nothing else they've used: no servers, no fixed cost, no warning before it scales — and a set of hard edges nobody puts on one page. This is that page. It's part of myDecodedseries (the study guide crowd will recognize the format).
Lambda in 60 seconds
The deal: you upload code, and AWS handles everything else — servers, OS patching, scaling, availability. Your function sits idle until an event triggers it: an HTTP request, a file landing in S3, a queue message, a schedule. You pay only for the moments your code is actually running.
Two facts explain most of Lambda's personality:
- **The memory slider is the CPU slider.**You pick memory from 128 MB to 10,240 MB, and CPU power scales with it proportionally — 1,769 MB is the exact point where you get one full vCPU. More memory also means faster execution, so the "right" setting is usually found by testing, not guessing.
- **You're billed in two parts:**a request charge and a duration charge, measured in GB-seconds (memory × runtime). Nobody's bill is driven by the number of requests alone.
What it actually costs
The published rates:$0.20 per 1 million requestsand**$0.0000166667 per GB-second**(x86 — roughly 20% less on Arm/Graviton). Those decimals are hard to feel, so let's make them concrete.
The intuition:a function at 512 MB that finishes in 100 ms costs about $0.00000083 per call. A million such calls cost$0.83— and your always-free tier covers the first 1M requests plus 400,000 GB-seconds every month, permanently. Most hobby projects stay at $0 forever.
**The reality check:**a busy function at 1 GB averaging 400 ms, invoked 10 million times in a month:
Line | Math | Cost |
|---|---|---|
Duration | 4,000,000 GB-s × $0.0000166667 | $66.67 |
Requests | 10M × $0.20/1M | $2.00 |
Total | | $68.67 |
After free tier | (3.6M GB-s + 9M requests) | $61.80 |
Notice what dominates:**duration, not requests.**Cost optimization on Lambda means shaving milliseconds and right-sizing memory — not worrying about call volume.
The numbers that matter
Every tutorial showssomeof these. Here's all of them, and which ones AWS can never raise:
Limit | Value | Hard or soft |
|---|---|---|
Memory | 128 MB – 10,240 MB (1 MB steps) | Hard |
Timeout | 900 seconds (15 min) — per invocation | Hard |
Ephemeral disk (/tmp) | 512 MB free, up to 10,240 MB (paid above) | Hard |
Deployment package (zip) | 50 MB zipped / 250 MB unzipped, layers included | Hard |
Deployment package (container) | 10 GB | Hard |
Payload — synchronous | 6 MB | Hard |
Payload — asynchronous | 1 MB(raised from 256 KB in Oct 2025 — old tutorials are wrong) | Hard |
Environment variables | 4 KB total | Hard |
Concurrent executions | 1,000 per region, default | Soft — raisable |
Code storage | 300 GB | Soft-ish |
The soft/hard split saves support tickets: concurrency you can request more of; the 15-minute wall you negotiate with architecture instead.
The part tutorials skip: what happens between two invocations
Between calls, Lambda doesn't keep your code "running." It freezes the execution environment — the sandbox — and hands it to the next event. First invocation pays setup; later ones reuse the warm sandbox; and at any moment, unseen, the sandbox can be recycled and rebuilt from scratch.
That single mechanism is behind most Lambda surprises: cold starts, the /tmp myths, and state that vanishes overnight.
[EMBED
lambda_invocation_lifecycle.png HERE]Seven gotchas, in the order people hit them
**1. The cold start tax.**First invocation (or first after a recycle) provisions an environment and runs your init code before the handler — and that setup time is billed to the caller. Fix: keep packages lean, do SDK clients and connectionsoutsidethe handler so warm invocations skip them, give latency-critical functions more memory (more CPU = faster init), and use provisioned concurrency only where every millisecond matters — you pay rent to keep instances warm.
**2. The 15-minute wall.**900 seconds is a hard limit, no exceptions. The classic failure is a queue consumer that assumes unlimited time. Fix: split long jobs into chunks with Step Functions orchestrating, or move the workload to Fargate.
**3. Timeout mismatch.**Your function's timeout exists relative to everyoneelse'stimeout. API Gateway gives you 29 seconds before it cuts the connection — while your Lambda keeps running and keeps billing. SQS makes it worse: if the queue's visibility timeout is shorter than your function's, the message reappears mid-processing and gets handled twice. Fix: caller timeout > function timeout > expected p99 latency, and align visibility timeouts accordingly.
4. The /tmp persistence myth./tmpmaysurvive between warm invocations — right up until it doesn't. Files from yesterday's test run "mysteriously" appearing, then disappearing, is /tmp being /tmp. Fix: it's a disposable cache. Real state belongs in S3, DynamoDB, or a database.
**5. The recursive loop.**A function triggered by S3 that writes back to the same bucket can trigger itself forever — a self-inflicted DDoS on your own bill. AWS now auto-detects and stops these loops (around 16 invocations) for Lambda ↔ SQS/SNS/S3, with EventBridge support added in October 2026. Good safety net — but don't lean on it. Design outputs to never re-trigger their own inputs.
**6. One noisy function starves the account.**The 1,000 concurrent executions limit is shared per region. One function in a traffic spike can throttle every other function you own. Fix: set a reserved concurrency cap on noisy functions, and request a limit raise before launch, not after.
**7. Logging is a bill too.**Every
print() ships to CloudWatch Logs, and ingestion costs money. A debug logger in a hot path is real cash at scale, and log groups default toNever Expireretention. Fix: log at proper levels, set retention on every log group you create.When NOT to use Lambda
Lambda is a hammer, and not everything is a nail:
- **Sustained heavy load.**A function pegged 24/7 costs more than an always-on container. Serverless wins on spiky and idle-heavy workloads, loses on steady utilization.
- **Jobs over 15 minutes.**Video encoding, big batch ETL — architect around the wall or pick another compute.
- **Ultra-low latency.**Cold starts make consistent sub-100ms responses a gamble unless you pay for provisioned concurrency.
- **Huge models, heavy state.**A 10 GB container image with a cold start on every scale-out is pain by design.
Which brings us to the newest chapter:Lambda Managed Instances(announced at re:Invent 2025) — running Lambda event functions on a pool of your own EC2 instances, Graviton4 included, with multiple invocations sharing one environment. It's AWS admitting that some workloads want Lambda's simplicityandEC2's shape. For steady, predictable, high-throughput jobs, it's now a legitimate third answer.
Workload | Best fit |
|---|---|
Event-driven, spiky, idle most of the time | Lambda |
Container-based, runs minutes at a time | Fargate |
Steady, heavy, predictable | EC2 — or Lambda Managed Instances |
The 10-minute starter recipe
- Create a function (Python or Node.js — start with the console blueprint).
- Add aFunction URL(free) so you can curl it in seconds — no API Gateway needed for a first test.
- Run a test event, watch the execution output.
- Set memory to 512 MB as a sane default, and timeout to something honest (not the full 15 minutes).
- Open the function's log group and set retention to one week. Do it now, thank yourself later.
That's the same setup as the $20 Free Tier activity — so you'll earn credits while you learn it.
TL;DR
- You pay for requests ($0.20/1M) and duration ($0.0000166667/GB-s) — duration dominates real bills; optimize milliseconds and memory, not call count.
- Memory slider = CPU slider; 1,769 MB = one full vCPU.
- The hard edges: 15 minutes, 10 GB memory, 6 MB sync / 1 MB async payloads, 250 MB unzipped packages.
- Cold starts, /tmp amnesia, recursive loops, and shared concurrency are the four surprises — each has a two-line fix above.
- Spiky event-driven work → Lambda. Long containers → Fargate. Steady and heavy → EC2 / Managed Instances.
- And if you're new to AWS entirely, start with the Free Tier survival guide — [PASTE YOUR PREVIOUS ARTICLE LINK HERE] — and vote the Free Tier dashboard wish if cost surprises keep biting you: [PASTE YOUR WISH LINK HERE]
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article