CloudGuild · Blog · Cheat sheets · Lessons · Certifications
AWS Lambda — Serverless Functions: When to Use What (and How the Exam Tests It)
Explore when to choose AWS Lambda for serverless functions and how the SAA-C03 exam tests your knowledge on this decision.
AWS Lambda provides event-driven functions that AWS manages and scales. You don’t have to worry about servers. You only pay for what runs. This makes it an attractive option for many use cases.
When to Choose AWS Lambda
Event-Driven Workflows
AWS Lambda shines when integrating with event sources. Use it for:- S3 uploads
- DynamoDB streams
- API Gateway
- EventBridge
Spiky or Unpredictable Loads
If your workload spikes, Lambda is a good choice. You avoid paying for idle EC2 instances.Short Tasks
Tasks must fit within the 15-minute execution limit. For longer jobs, consider ECS, Fargate, or EC2.
Comparison Table: AWS Lambda vs. EC2/Fargate
| Feature | AWS Lambda | EC2/Fargate |
|---|---|---|
| Server Management | No | Yes |
| Execution Time Limit | 15 minutes | No |
| Cost Model | Pay-per-use | Pay for instance hours |
| Ideal for | Short, event-driven | Long-running tasks |
Key Architectural Decisions
Concurrency
Understand the difference between reserved and provisioned concurrency. This is crucial for latency-sensitive applications.Cold Starts
Minimize cold starts by using provisioned concurrency or lighter runtimes. Cold starts can slow down function responses.Single-Purpose Functions
Keep functions focused on single tasks. Use AWS Step Functions for orchestration instead of creating large, complex handlers.
Gotchas & Exam Traps
- Remember the 15-minute max runtime for AWS Lambda. Long-running jobs should use ECS, Fargate, or EC2.
- Be cautious with package size, ephemeral storage, and memory limits. These factors will shape your design decisions.
- The exam rewards understanding the Lambda model: no server management, automatic scaling, and pay-per-use are key indicators.
How the Exam Tests This
Scenario-Based Questions
Expect questions that present a scenario requiring event-driven architecture. Identify if Lambda is the right fit based on workload characteristics.Concurrency Management
Questions may focus on reserved vs. provisioned concurrency. Knowing when to apply each is crucial for performance-related questions.Cold Start Considerations
You may face questions on mitigating cold starts. Understand the implications of using provisioned concurrency versus standard invocation.
The Rule to Remember
AWS Lambda is best for short, event-driven tasks. Use it for integration and processing, but switch to containers for longer, specialized workloads.