Quizzes · Compute · Level 0
Lambda
Upload a function; AWS runs it only when something calls it.
Think of it as: A taxi. You pay for the ride, not for owning the car.
What to know for Level 0
- A function runs for at most 15 minutes. Longer jobs belong on Fargate, or need splitting up.
- You pay per request and per millisecond of run time (scaled by memory size). An idle function costs nothing.
- By default a function runs outside your VPC and can reach public AWS services. Attach it to a VPC only to reach private things like RDS; then it needs a NAT gateway to reach public services.
- Each function has exactly one execution role: everything its code can do in AWS.
- Lambda sends whatever a function prints to CloudWatch Logs automatically, as long as the execution role allows writing logs.
- Lambda polls an SQS queue for you (an event source mapping). Set the queue's visibility timeout to at least six times the function's timeout, or messages get processed twice.
- AWS runs the servers, the operating system and the scaling. Your code, and what its role allows, stay yours.
What to know for Level 1
- A function's size is its memory, from 128 MB to 10,240 MB, and CPU is allotted in proportion. A CPU-bound function often gets faster, and sometimes cheaper, with more memory.
What to know for Level 2
- Concurrency is how many invocations run at once. A Region has a shared limit (1,000 by default, can be raised). Reserved concurrency guarantees a function some of it and also caps it.
- A cold start is the delay while Lambda prepares a new execution environment. Provisioned concurrency keeps environments initialized ahead of time, removing cold starts for a steady cost.
- When concurrency runs out, synchronous calls are throttled (HTTP 429) and asynchronous events are retried for a while; putting a queue in front smooths bursts.
- For the event source mapping to work, the function's execution role must allow sqs:ReceiveMessage, sqs:DeleteMessage and sqs:GetQueueAttributes on the queue (the AWSLambdaSQSQueueExecutionRole managed policy has them). Without them messages simply stay in the queue.
- Any AWS service that calls a function (API Gateway, an ALB, EventBridge, S3, SNS) needs a resource-based policy on the function that names that service. The console wizards add it; infrastructure code must add it. The function's execution role is a separate thing: it only covers what the code does once running.
More detail
There’s no server to manage and you pay per request and per millisecond. A function runs for at most 15 minutes. By default it runs outside your VPC; attach it to a VPC when it needs to reach private things like an RDS database.
Quiz yourself on Lambda →Study flash cards
← All quizzes