Running apps on AWS · mid
Lambda behind an API
A Lambda function is a handler that receives an event (for HTTP, from API Gateway or a function URL) and returns a status, headers and body; one instance handles one request at a time, code outside the handler is reused while the instance is warm, and new instances pay a cold start.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Handler: export const handler = async (event, context) => ({ statusCode, headers, body }). For API Gateway HTTP APIs (payload v2), the event has routeKey, rawPath, pathParameters, queryStringParameters, headers, body (a string, maybe base64) and requestContext.http.method.
- Front doors: API Gateway (HTTP API is simpler and cheaper than REST API; REST API has more features), Lambda function URLs, or an ALB.
- Cold start: a new instance downloads code and runs init. Keep bundles small, create SDK clients and DB pools outside the handler (reused while warm). SnapStart does not support Node.js; provisioned concurrency keeps instances warm for a price.
- Concurrency: each instance serves one request at a time, so 500 concurrent requests = 500 instances (and potentially 500 DB connections: use RDS Proxy).
- Limits: 15-minute maximum run time; API Gateway's integration timeout is much shorter (about 30 s), so long work goes to a queue.
- Node runtimes: nodejs22.x and nodejs24.x (nodejs20.x deprecated 30 April 2026; nodejs26.x in preview). Response streaming lets a function stream up to 200 MB (useful for SSR and AI output).
- New in late 2025: Lambda Managed Instances (Lambda on AWS-managed EC2 capacity) and durable functions for long multi-step workflows.
The red pen
Common traps: mistake → fix
Mistake: Each request gets a brand-new process
Fix: warm instances reuse globals, so module-level state leaks between requests unless you are careful.
Mistake: Lambda can hold a 10-minute HTTP request behind API Gateway
Fix: the gateway times out long before; use a queue and polling or webhooks.
Easy to hard
Questions interviewers ask, easy to hard
- How does a request reach a Lambda function and come back?
- What is a cold start and how do you reduce it?
- Why do Lambdas exhaust database connections, and how do you fix it?
- What would you never do in a Lambda handler?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.