AWS Serverless Architecture and AWS Lambda 5 — Questions and Answers
Question 1: A developer wants to reuse common libraries across multiple Lambda functions without duplicating code. What is the recommended approach?
- Package the libraries in each deployment ZIP separately
- Use Lambda Layers to share common dependencies (Correct answer)
- Store libraries in S3 and download at runtime
- Use EFS mounted to all Lambda functions
Correct answer: Use Lambda Layers to share common dependencies
Lambda Layers allow you to package shared libraries, dependencies, or custom runtimes separately and attach them to multiple functions.
Question 2: What happens to a Lambda function's environment variables when you publish a new version?
- Environment variables are not included in published versions
- Environment variables are snapshotted and immutable in the published version (Correct answer)
- Environment variables are shared across all versions
- Environment variables are reset to defaults in new versions
Correct answer: Environment variables are snapshotted and immutable in the published version
When you publish a Lambda version, the environment variables are included in the snapshot and become immutable for that specific version.
Question 3: A serverless application needs to fan out a single event to multiple downstream Lambda functions simultaneously. Which pattern is most appropriate?
- Chain Lambda functions sequentially using Lambda Destinations
- Publish the event to SNS and subscribe multiple Lambda functions (Correct answer)
- Use SQS FIFO to deliver the event to multiple consumers
- Use API Gateway to proxy to multiple Lambda functions
Correct answer: Publish the event to SNS and subscribe multiple Lambda functions
SNS enables a fan-out pattern where a single published message is delivered to all subscribed Lambda functions simultaneously.
Question 4: Which Lambda concurrency type pre-warms execution environments to eliminate cold starts entirely?
- Reserved Concurrency
- Burst Concurrency
- Provisioned Concurrency (Correct answer)
- On-demand Concurrency
Correct answer: Provisioned Concurrency
Provisioned Concurrency pre-initializes a specified number of execution environments so they are always ready to respond without cold start latency.
Question 5: A Lambda function is processing S3 events but occasionally fails and you want failed events routed to an SQS queue automatically. What feature enables this?
- S3 Event Notification retry policy
- Lambda Dead Letter Queue (DLQ) configuration
- Lambda Destinations for asynchronous invocations (Correct answer)
- CloudWatch Events rule with SQS target
Correct answer: Lambda Destinations for asynchronous invocations
Lambda Destinations for asynchronous invocations allow you to route failed events to an SQS queue, SNS topic, EventBridge, or another Lambda function.
Question 6: What is the default ephemeral storage size available in /tmp for a Lambda function, and what is the maximum?
- 256 MB default, 512 MB maximum
- 512 MB default, 10 GB maximum (Correct answer)
- 512 MB default, 512 MB maximum
- 1 GB default, 10 GB maximum
Correct answer: 512 MB default, 10 GB maximum
Lambda provides 512 MB of /tmp ephemeral storage by default, which can be configured up to 10 GB for functions requiring larger temporary storage.
Question 7: An AWS Lambda function invoked by API Gateway must return a response within how many seconds before API Gateway times out?
- 15 seconds
- 29 seconds (Correct answer)
- 60 seconds
- 300 seconds
Correct answer: 29 seconds
API Gateway has a maximum integration timeout of 29 seconds, so Lambda functions invoked synchronously via API Gateway must complete within this limit.
A developer wants to reuse common libraries across multiple Lambda functions without duplicating code.
What is the recommended approach?