Service · Serverless · Builds on CLF-C02
AWS Lambda
Size memory, plan concurrency and cold starts, and know how each trigger calls a function.
You know from Cloud Practitioner
- Runs code on events. No servers. Pay per request and run time.
- Triggered by S3, API Gateway, SQS, EventBridge and more.
- A run has a time limit.
Synchronous
- Called by
- API Gateway, load balancer
- On error
- The caller sees it and retries
Asynchronous
- Called by
- S3, SNS, EventBridge
- On error
- Two retries, then destination or DLQ
Poll-based
- Called by
- SQS, Kinesis, DynamoDB Streams
- On error
- Batch is retried. SQS message returns to the queue
| Mode | Called by | On error |
|---|---|---|
| Synchronous | API Gateway, load balancer | The caller sees it and retries |
| Asynchronous | S3, SNS, EventBridge | Two retries, then destination or DLQ |
| Poll-based | SQS, Kinesis, DynamoDB Streams | Batch is retried. SQS message returns to the queue |
Memory
- What it does
- Sets memory and CPU
- Use it to
- Speed up CPU-bound code
Reserved concurrency
- What it does
- Guarantees and caps a function
- Use it to
- Protect a database
Provisioned concurrency
- What it does
- Keeps environments ready
- Use it to
- Remove cold starts
SnapStart
- What it does
- Starts from a saved snapshot
- Use it to
- Cut cold starts in Java
| Setting | What it does | Use it to |
|---|---|---|
| Memory | Sets memory and CPU | Speed up CPU-bound code |
| Reserved concurrency | Guarantees and caps a function | Protect a database |
| Provisioned concurrency | Keeps environments ready | Remove cold starts |
| SnapStart | Starts from a saved snapshot | Cut cold starts in Java |
1 / 2
Memory
- What it does
- Sets memory and CPU
- Use it to
- Speed up CPU-bound code
Reserved concurrency
- What it does
- Guarantees and caps a function
- Use it to
- Protect a database
Provisioned concurrency
- What it does
- Keeps environments ready
- Use it to
- Remove cold starts
| Setting | What it does | Use it to |
|---|---|---|
| Memory | Sets memory and CPU | Speed up CPU-bound code |
| Reserved concurrency | Guarantees and caps a function | Protect a database |
| Provisioned concurrency | Keeps environments ready | Remove cold starts |
2 / 2
SnapStart
- What it does
- Starts from a saved snapshot
- Use it to
- Cut cold starts in Java
| Setting | What it does | Use it to |
|---|---|---|
| SnapStart | Starts from a saved snapshot | Cut cold starts in Java |
What it is
Memory is the main performance setting. It runs from 128 MB to 10,240 MB, and CPU grows with it. At 1,769 MB a function has the power of one vCPU. A CPU-bound function often runs faster at a higher setting, and may cost about the same because it runs for less time. The timeout is set per function. The current documented maximum is 30 minutes, and older material says 15. Longer work belongs on Fargate, AWS Batch or EC2. A synchronous call carries up to 6 MB.
What it is
The default is 1,000 concurrent executions per Region, shared by all functions. New accounts may start with a lower limit. AWS raises it as you use Lambda. Reserved concurrency guarantees capacity to one function and also caps it, which protects a database from too many connections. Provisioned concurrency keeps environments ready, which removes cold starts for user-facing paths, at extra cost. SnapStart starts from a saved snapshot to cut cold starts for supported runtimes such as Java.
What it is
Triggers call in three ways. Synchronous: the caller waits and handles errors. Asynchronous: Lambda queues the event and retries twice, then sends it to a destination or a dead-letter queue. Poll-based: Lambda reads batches from SQS, Kinesis or DynamoDB Streams. To reach private resources, attach the function to a VPC. It then needs a NAT gateway or VPC endpoints to reach the internet or AWS services. Layers share libraries across functions.
Remember
- Memory 128 MB to 10,240 MB. CPU scales with it. About 1,769 MB is one vCPU.
- Reserved concurrency guarantees and caps. Provisioned concurrency removes cold starts.
- Default 1,000 concurrent executions per Region, shared by all functions. New accounts may start lower.
- Sync: caller waits. Async: queued, retried twice, then destination or DLQ. Poll-based: batches.
Remember
- In a VPC, a function needs NAT or endpoints to reach the internet or AWS services.
- Payload limits: 6 MB for sync calls, 1 MB for async.
On the exam
- “Function is slow and CPU-bound” points to more memory.
- “Remove cold start latency for a user-facing API” points to provisioned concurrency.
- “Protect a database from too many connections” points to reserved concurrency.
- “Keep failed async events for later” points to an on-failure destination or a dead-letter queue.
- “Job runs longer than the time limit” points to Fargate or AWS Batch.
Do not mix it up with
AWS FargateTask sizes, storage, Fargate Spot, and when Fargate beats EC2 nodes.
AWS BatchJob queues, compute environments, array jobs and dependencies, and when Batch beats Lambda, Glue or EMR.
Amazon Simple Queue Service (Amazon SQS)The settings that decide behavior: visibility timeout, long polling, delay, retention, DLQs, and scaling on queue depth.