# AWS Lambda

> My default for event-driven work and heavy compute. Classic Lambda, zip-packaged, Node.js.

- Verdict: My default
- Vendor: AWS
- Layer: [Compute](https://cloudlesslabs.com/stack/layers/compute.md). Job: Events and heavy compute
- Last reviewed: 18 October 2026, by Nicolas Dao (Cloudless Labs, Sydney)
- Web page: https://cloudlesslabs.com/stack/aws-lambda/. The whole stack in one file: https://cloudlesslabs.com/stack/brief.md

Lambda is still where most of my business logic lives. It's the glue for everything AWS emits, and nothing else gives me IAM, VPC access and 30-odd event sources in one place.

But I no longer treat it as the answer to every HTTP request. For work that mostly waits, Lambda bills you for the waiting. Cloudflare Workers at the edge, and Lambda Web Functions once they reach my clients' regions, do that job better.

## Use it when

- The trigger is an AWS event (SQS, SNS, EventBridge, S3, Cognito, DynamoDB or Kinesis streams, scheduled jobs).
- You need memory or CPU per request (up to 10 GB, native modules, Chromium PDFs, sharp, ffmpeg).
- Data must stay in an AWS region, including Sydney.
- You need private VPC resources or IAM-native calls to other AWS services.
- Low-traffic functions the free tier covers entirely.

## Don't use it when

- The work is mostly waiting on something else (LLM streaming, slow APIs). You pay for the wait. Use Workers or Lambda Web Functions.
- Sudden spikes from zero to tens of thousands of requests a second: Lambda adds at most 1,000 instances per 10 seconds per function, capped by the account default of 1,000, and each new one cold-starts. Put Workers in front.
- WebSockets and real-time fan-out. Use Workers with Durable Objects.

## Pricing

$0.20 per million requests + $0.0000133334/GB-s on Arm ($0.0000166667 on x86). Free tier: 1M requests and 400,000 GB-s a month, always.

## In my words: what hurts

- Cold starts.
- Functions left idle for weeks break on the next visit instead of just being slow.
- Retry, timeout and dead-letter settings with SQS must be exactly right or messages end up in the DLQ.
- AWS retires Node.js runtimes on its own calendar, so every function needs an upgrade every couple of years.

## Gotchas, with fixes

- **Gotcha:** A function idle for weeks goes Inactive, and the first calls fail while it reactivates.
  **Fix:** Ping it on a schedule, use provisioned concurrency for critical paths, or move bursty HTTP endpoints to Workers.
- **Gotcha:** Scaling is capped: 1,000 concurrent executions per account by default, and each function adds at most 1,000 instances every 10 seconds.
  **Fix:** The limit is requests in flight, not per second (2,000 req/s at 100 ms is only 200). Raise the quota before launches, and put Workers in front of known spikes.
- **Gotcha:** SnapStart doesn't help Node.js. As of October 2026 it only supports Java, Python, .NET and container images.
  **Fix:** For Node.js zip functions, keep the bundle small, initialise lazily, and use provisioned concurrency where latency matters.
- **Gotcha:** Log-level filtering (drop DEBUG and INFO before you pay for them) only works with the JSON log format. The default Text format logs everything.
  **Fix:** Set the log format to JSON and the application log level to WARN in production.
- **Gotcha:** Response streaming isn't available through a function URL when the function is in a VPC.
  **Fix:** Keep streaming endpoints out of the VPC, or stream from Workers or Lambda Web Functions.

## Provisioning

Official Pulumi package · Official Terraform provider

@pulumi/aws, mature, everything GA.

## Instead, consider

- [Lambda Web Functions](https://cloudlesslabs.com/stack/aws-lambda-web-functions/index.md): HTTP business logic that mostly waits on a database, once it's in your region.
- [Cloudflare Workers](https://cloudlesslabs.com/stack/cloudflare-workers/index.md): The edge, long waits, spikes, webhooks and WebSockets.
- [Fargate scheduled tasks](https://cloudlesslabs.com/stack/aws-fargate-scheduled-tasks/index.md): Jobs longer than 15 minutes.

## Worked examples

- [Lambda, Web Functions or Workers?](https://cloudlesslabs.com/stack/guides/compute-choice/index.md): Where should this piece of logic run?
- [The LLM streaming proxy](https://cloudlesslabs.com/stack/guides/llm-proxy/index.md): How do I add an AI chat feature without leaking my API key or paying for the model's thinking time?
- [The flash sale](https://cloudlesslabs.com/stack/guides/flash-sale/index.md): What happens when 50,000 people press "Buy" in the same ten seconds?

## Where it fits

- [A traffic spike I can see coming](https://cloudlesslabs.com/stack/use-cases/flash-sale.md): pick 3. Calm checkout for the winners only. Behind the Worker and the counters, Lambda sees the 2,000 winners, not 50,000 people in ten seconds.
- [Background jobs and retries](https://cloudlesslabs.com/stack/use-cases/background.md): pick 2. Batched consumers with partial batch failures.
- [An AI chat or LLM feature](https://cloudlesslabs.com/stack/use-cases/ai-chat.md): don't. Not as the proxy. Lambda bills for every second the function waits on the model, and a streamed answer takes 10–60 seconds. A Worker bills CPU time only, so waiting is free: $33–167 vs about $0 extra for 1M chats. Keep Lambda for the work behind the proxy. Instead: [Cloudflare Workers](https://cloudlesslabs.com/stack/cloudflare-workers/index.md).

## In The Stack Weekly

- [Week 43: Lambda Web Functions](https://cloudlesslabs.com/weekly/2026-w43/index.md), watching

## Sources

- [AWS Lambda pricing](https://aws.amazon.com/lambda/pricing/)
- [Lambda quotas](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html)
- [Lambda SnapStart](https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html)

## Related

- [Compute](https://cloudlesslabs.com/stack/layers/compute.md): every tool in this layer, with its verdict
- [The whole stack in one file](https://cloudlesslabs.com/stack/brief.md): every use case and tool, for questions that span many
- [Map of every Markdown file on cloudlesslabs.com, with what each one answers](https://ask.cloudlesslabs.com)
