AWS Serverless Architecture and AWS Lambda 4 — Questions and Answers
Question 1: A Lambda function needs to process messages from an SQS queue but should stop retrying a message after 3 failed attempts. What should you configure?
- Set the SQS visibility timeout to match the Lambda timeout
- Configure a Dead Letter Queue (DLQ) on the SQS event source mapping with maxReceiveCount=3 (Correct answer)
- Use Lambda Destinations to route failures to another SQS queue
- Enable Lambda Reserved Concurrency to limit processing attempts
Correct answer: Configure a Dead Letter Queue (DLQ) on the SQS event source mapping with maxReceiveCount=3
Setting maxReceiveCount on the SQS event source mapping's redrive policy sends messages to a DLQ after the specified number of failed processing attempts.
Question 2: Which Lambda feature allows you to run a portion of traffic on a new version while keeping most traffic on a stable version?
- Lambda Layers
- Lambda Aliases with weighted routing (Correct answer)
- Lambda Provisioned Concurrency
- Lambda Environment Variables
Correct answer: Lambda Aliases with weighted routing
Lambda aliases support weighted routing, allowing you to split traffic between two function versions for canary or blue/green deployments.
Question 3: A Lambda function reads from DynamoDB Streams. The function is failing and the stream iterator keeps replaying the same batch. What is the most likely cause?
- The Lambda function timeout is set too low
- The Lambda function is throwing an unhandled exception, causing the batch to retry (Correct answer)
- DynamoDB Streams retention period has expired
- The Lambda reserved concurrency is set to 0
Correct answer: The Lambda function is throwing an unhandled exception, causing the batch to retry
When a Lambda function throws an unhandled exception processing a DynamoDB Stream batch, the batch is retried until it succeeds or the retention period expires.
Question 4: What is the maximum execution timeout for an AWS Lambda function?
- 5 minutes
- 10 minutes
- 15 minutes (Correct answer)
- 30 minutes
Correct answer: 15 minutes
AWS Lambda functions have a maximum execution timeout of 15 minutes (900 seconds).
Question 5: An application uses Lambda with API Gateway. During a traffic spike, some requests receive 429 errors. What is the root cause?
- API Gateway stage throttling limits were exceeded
- Lambda function memory is insufficient
- The Lambda function's reserved concurrency limit was reached
- Both A and C are possible causes (Correct answer)
Correct answer: Both A and C are possible causes
429 Too Many Requests errors from API Gateway + Lambda can result from API Gateway throttling limits OR Lambda concurrency limits being exhausted.
Question 6: You want a Lambda function to access resources inside a private VPC without internet access. What must you configure?
- Attach an Elastic IP to the Lambda function
- Configure Lambda with VPC settings specifying subnets and security groups (Correct answer)
- Use a NAT Gateway in the public subnet
- Enable Lambda PrivateLink
Correct answer: Configure Lambda with VPC settings specifying subnets and security groups
To access VPC resources, Lambda must be configured with VPC settings including the target subnets and security groups, which creates ENIs in your VPC.
Question 7: Which AWS service can be used to orchestrate multiple Lambda functions into a workflow with branching logic, error handling, and retries?
- Amazon SQS
- AWS Step Functions (Correct answer)
- Amazon EventBridge
- AWS AppSync
Correct answer: AWS Step Functions
AWS Step Functions allows you to build state machines that orchestrate Lambda functions with support for branching, parallel execution, error handling, and automatic retries.
A Lambda function needs to process messages from an SQS queue but should stop retrying a message after 3 failed attempts.
What should you configure?