Lambda & Serverless
AWS SAA SAA-C03 · Design High-Performing Architectures
AWS Lambda: functions without servers
AWS Lambda runs your code in response to events without you provisioning or managing any servers. You upload code (or a container image), define a trigger, and Lambda runs it, scales it automatically, and charges you only for the requests and the compute time consumed. Each invocation is independent: Lambda can run thousands of copies of your function in parallel when events spike, and scale to zero when there is nothing to do. That makes it ideal for event-driven work — processing files uploaded to S3, responding to API calls, reacting to database changes, running scheduled tasks.
Lambda has limits the exam tests. A single invocation can run for at most 15 minutes, so Lambda is the wrong choice for long-running jobs (those belong on EC2, ECS, or AWS Batch). Memory is configurable from 128 MB to 10 GB, and CPU scales proportionally with memory — doubling memory doubles CPU, which is also how you buy more performance. Functions get 512 MB of ephemeral storage at /tmp by default (configurable up to 10 GB), and can mount an EFS file system for shared or persistent data. A function's execution role (an IAM role) determines what AWS resources it can touch. Lambda runs in the AWS-managed network by default; if a function needs to reach resources inside your VPC (such as an RDS database), you configure VPC access, and the function then uses elastic network interfaces in your subnets.
Cold starts are the startup delay when Lambda has to initialize a new execution environment for a function that has not run recently. For most workloads the delay is negligible, but for latency-sensitive APIs it matters. Provisioned concurrency keeps a number of execution environments warm and ready, eliminating cold starts at an extra cost. The exam's rule: provisioned concurrency is the answer when a question explicitly requires consistent low latency from Lambda.
Building serverless applications: API Gateway, Step Functions, and EventBridge
Lambda rarely stands alone. Amazon API Gateway exposes Lambda functions (and other backends) as HTTP APIs, handling request routing, authentication, throttling, request validation, and caching. It offers REST APIs (full-featured) and HTTP APIs (cheaper, lower latency, fewer features). API Gateway can also throttle requests to protect a backend from being overwhelmed, and it integrates with Cognito and Lambda authorizers for authentication.
AWS Step Functions orchestrate multi-step workflows: a sequence of Lambda functions, with branching, retries, parallel steps, and error handling, expressed as a state machine. When a question describes a workflow where step B depends on step A, with error handling and human approval steps, Step Functions is the answer — not a single giant Lambda function, and not a chain of functions calling each other directly. Amazon EventBridge is the serverless event bus: it routes events between AWS services, SaaS applications, and your own applications based on rules, and it can trigger targets on a schedule (replacing the older CloudWatch Events scheduled rules).
Decoupling: SQS and SNS
Two messaging services appear constantly in the exam, and the distinction between them is fundamental. Amazon SQS (Simple Queue Service) is a message queue: producers send messages, consumers pull them and process them at their own pace. Queues decouple components, so a slow consumer does not block a fast producer, and messages are buffered during traffic spikes instead of being lost. SQS offers standard queues (at-least-once delivery, best-effort ordering, nearly unlimited throughput) and FIFO queues (exactly-once processing, strict ordering, lower throughput). A message that fails processing repeatedly can be moved to a dead-letter queue (DLQ) after a configured number of receives, so poison messages do not block the queue forever. The visibility timeout is the period during which a message being processed is hidden from other consumers; it should be longer than the time processing takes, or the message will be processed twice.
Amazon SNS (Simple Notification Service) is a publish/subscribe service: a publisher sends one message to a topic, and SNS delivers it to all subscribers — which can be SQS queues, Lambda functions, HTTP endpoints, email addresses, or mobile push notifications. SNS is for fan-out: one event, many consumers. The classic exam pattern combines them: SNS fans a message out to multiple SQS queues, one per consumer type, so each consumer processes at its own pace. The rule of thumb: SQS is one-to-one (a message is processed by one consumer), SNS is one-to-many (a message goes to all subscribers). When a question says several independent systems must all react to the same event, the answer is SNS; when it says work must be queued and processed reliably at the consumer's pace, the answer is SQS.
Serverless design judgment
The exam tests serverless as a design choice, not just as a list of services. Lambda wins when workloads are event-driven, short-lived, spiky, or idle much of the time. EC2 or containers win when workloads run continuously, need more than 15 minutes per task, or need specific operating-system-level control. Decoupling with SQS or SNS wins whenever two components have different speeds or availability requirements — the queue absorbs the difference. And the serverless cost model (pay per use) usually beats paying for idle servers, except for sustained high-volume workloads where reserved capacity is cheaper.
Operating Lambda functions
Running Lambda in production involves a few more concepts. Versions and aliases let you publish immutable snapshots of a function and point an alias (such as “production”) at a specific version, so you can roll back instantly and shift traffic gradually between versions for safe deployments. Environment variables hold configuration, and sensitive values should be encrypted with KMS or, better, fetched from Secrets Manager or Parameter Store at runtime rather than stored in the function configuration. Layers package shared libraries and dependencies separately from function code, so many functions can reuse the same layer without duplicating it. Destinations route the result of an asynchronous invocation — success or failure — to another service such as an SQS queue, an SNS topic, an EventBridge event bus, or another Lambda function, which makes it easy to build reliable pipelines that handle failures explicitly instead of silently dropping them.
Lambda also has concurrency controls worth knowing. Each Region has a default concurrency limit (1,000 concurrent executions), and you can set reserved concurrency for a function to guarantee it capacity or to cap how much it can consume — useful both to protect a critical function from being starved and to prevent a runaway function from exhausting the account's capacity or overwhelming a downstream database. Failed asynchronous invocations are retried automatically (twice, by default) before being discarded, which is why a dead-letter queue or a failure destination matters for important workloads. Monitoring comes from CloudWatch: every function automatically reports invocations, errors, duration, and throttles, and CloudWatch Logs captures the function's output. For distributed tracing across functions and services, AWS X-Ray integrates with Lambda with minimal configuration.
Exam traps to watch for
- Using Lambda for work that takes longer than 15 minutes. The 15-minute maximum execution time is a hard limit — long jobs need EC2, ECS, or AWS Batch.
- Confusing SQS with SNS: SQS is a queue (one consumer processes each message); SNS is pub/sub fan-out (every subscriber gets the message).
- Forgetting the visibility timeout: if it is shorter than the processing time, a message becomes visible again and gets processed twice.
- Chaining Lambda functions by having them call each other directly instead of using Step Functions for multi-step workflows with retries and error handling.
Practice questions
Test yourself on this guide. Answers are checked instantly, with a full explanation for each question.
Q1.A company processes images uploaded to S3. Each image takes about 30 seconds to resize, uploads arrive in unpredictable bursts, and there are long idle periods with no uploads. Which compute solution is MOST cost-effective?
Explanation: This is the textbook Lambda workload: short tasks (30 seconds, well under the 15-minute limit), event-driven, bursty, with idle periods where you pay nothing. Lambda scales automatically with the bursts and costs nothing when idle. Option C pays for servers around the clock including idle time. Option B still pays for 10 instances at minimum even when nothing is happening. Option A is designed for large-scale batch computing jobs, not for reacting to individual upload events.
Exam objective: SAA-C03 Task Statement 3.2: Design high-performing and elastic compute solutions
Q2.A video processing job runs for 45 minutes per file and must run to completion without interruption. The company is considering AWS Lambda for this workload. What should the solutions architect recommend?
Explanation: Lambda has a hard maximum execution time of 15 minutes per invocation, so a 45-minute uninterrupted job cannot run on Lambda. EC2, ECS, or AWS Batch are the right homes for long-running work. Option D states a wrong limit (15 minutes, not 60). Option B confuses provisioned concurrency, which eliminates cold starts, with execution time — it does not extend the 15-minute limit. Option C is a fragile workaround: splitting a job that must run to completion into chained invocations adds failure points and complexity for no benefit.
Exam objective: SAA-C03 Task Statement 3.2: Design high-performing and elastic compute solutions
Q3.An order-processing system receives orders through an API. Order volume spikes unpredictably, and the processing service is slower than the API. Orders must not be lost during spikes, and the API must respond quickly even when processing is backed up. Which design meets these requirements?
Explanation: An SQS queue decouples the fast API from the slower processor: the API returns immediately after enqueueing, messages are durably buffered during spikes so none are lost, and the processor works through the backlog at its own pace. Option C couples the two systems — during a spike the API would slow down or time out waiting for the processor. Option B is a polling anti-pattern: scanning a table is inefficient and adds latency. Option A loses every message, since a topic with no subscribers delivers to nobody.
Exam objective: SAA-C03 Task Statement 2.1: Design scalable and loosely coupled architectures
Q4.A company wants a single event — a new customer sign-up — to trigger three independent actions: send a welcome email, create a record in a CRM system, and notify an analytics service. Each action is handled by a different system. Which AWS service BEST delivers the event to all three systems?
Explanation: SNS is a publish/subscribe fan-out service: one message published to a topic is delivered to every subscriber, so the email system, CRM, and analytics service each get the event independently. Option A is a queue: each message is processed by one consumer, so only one of the three systems would get it. Option B does nothing without rules to route events to targets. Option C delivers the event to only one function, not three independent systems.
Exam objective: SAA-C03 Task Statement 2.1: Design scalable and loosely coupled architectures
Q5.A Lambda function processes messages from an SQS queue. Processing takes about 90 seconds per message, but the queue's visibility timeout is set to 30 seconds. What problem will occur?
Explanation: The visibility timeout hides a message from other consumers while it is being processed. At 30 seconds, the message becomes visible again long before the 90-second processing finishes, so another consumer can pick it up and process it a second time. The fix is to set the visibility timeout longer than the processing time. Option A is wrong: messages are only deleted when the consumer explicitly deletes them after successful processing. Option D confuses the queue's visibility timeout with the Lambda timeout, which is separate. Option B is wrong: the dead-letter queue only receives messages after a configured number of failed receives.
Exam objective: SAA-C03 Task Statement 2.1: Design scalable and loosely coupled architectures
Q6.A company is building an order workflow: validate the order, charge the payment, then ship the product. Each step depends on the previous one, failed steps must be retried, and a failed payment must stop the workflow. Which service BEST orchestrates this workflow?
Explanation: Step Functions is built for multi-step workflows: it expresses the sequence as a state machine with branching, retries, error handling, and the ability to stop on failure. Option C is a notification fan-out service with no workflow logic. Option B orders messages but does not orchestrate dependent steps with retries. Option D puts all the orchestration logic inside one function, which is hard to observe, retry, and maintain — and a single function cannot easily wait for human approval steps.
Exam objective: SAA-C03 Task Statement 2.1: Design scalable and loosely coupled architectures
Q7.A latency-sensitive API is backed by Lambda functions. Users report occasional slow responses of several seconds when the API has been idle. The slowness disappears under steady traffic. What is the MOST likely cause, and what is the BEST fix?
Explanation: The pattern — slow only after idle periods, fine under steady traffic — is the signature of cold starts: Lambda must initialize a new execution environment for the first invocation after a gap. Provisioned concurrency keeps environments warm so invocations start immediately. Option B misdiagnoses the problem: memory and timeout are unrelated to idle-period latency. Option D misses the cause entirely: VPC access only lets functions reach private resources, it does nothing for idle-period latency — and since AWS improved Lambda VPC networking in 2019, VPC attachment no longer adds meaningful cold-start delay either. Option C mixes unrelated concepts: API Gateway throttling returns errors rather than slow responses, and SQS depth has nothing to do with it.
Exam objective: SAA-C03 Task Statement 3.2: Design high-performing and elastic compute solutions
Q8.A Lambda function needs to query a private RDS database inside a VPC and also call an external payment API over the internet. What must the solutions architect configure for the function to reach both?
Explanation: A VPC-attached Lambda function uses elastic network interfaces in your subnets, so it can reach the private database directly — but it loses the default internet access that Lambda functions outside a VPC have. To reach the external payment API, the function's subnets need a route to a NAT gateway (in private subnets) for outbound internet traffic. Option A is wrong: VPC-attached functions do not get internet access automatically. Option D exposes the database to the internet, which is a serious security failure. Option C confuses IAM permissions (which authorize AWS API calls) with network connectivity.
Exam objective: SAA-C03 Task Statement 1.2: Design secure workloads and applications