AWS Lambda Interview Questions and Answers (Comprehensive Guide)

AWS Lambda

AWS Lambda is one of the most frequently asked topics in AWS, Data Engineering, Cloud Engineering, DevOps, Solution Architect, and AI/ML interviews.


1. What is AWS Lambda?

Answer

AWS Lambda is a serverless compute service that allows you to run code without provisioning or managing servers.

You upload your code, and Lambda automatically:

  • Executes the code
  • Scales automatically
  • Manages infrastructure
  • Handles availability and fault tolerance

Key Benefits

  • No server management
  • Pay only for execution time
  • Automatic scaling
  • Event-driven architecture
  • Supports multiple languages

Supported Languages:

  • Python
  • Java
  • Node.js
  • C#
  • Go
  • Ruby
  • Custom Runtime

2. What is Serverless Computing?

Answer

Serverless computing means developers focus only on code while AWS manages:

  • Servers
  • Operating Systems
  • Patching
  • Scaling
  • Availability

Example:

Traditional:

Application → EC2 → OS → Scaling → Monitoring

Serverless:

Application → Lambda

AWS manages everything else.


3. How does Lambda work?

Answer

Flow:

Event Source

AWS Lambda

Execution Environment

Response

Example:

File uploaded to S3

Lambda triggered

Process file

Store result in DynamoDB

4. What are Lambda Triggers?

Answer

Triggers are AWS services that invoke Lambda.

Common Triggers:

ServiceTrigger Event
S3Object Upload
DynamoDBTable Change
API GatewayAPI Request
SNSNotification
SQSMessage Arrival
EventBridgeScheduled Event
KinesisStream Event
CloudWatchAlarm
Step FunctionsWorkflow

5. Explain Lambda Architecture

Answer

Components:

Lambda Function
Runtime
Handler
Execution Role
Environment Variables
Layers
Triggers
Destination

Example:

Python Runtime
Handler: lambda_function.lambda_handler
Role: LambdaExecutionRole

6. What is a Lambda Handler?

Answer

Handler is the entry point of Lambda execution.

Python Example:

def lambda_handler(event, context):
return {
"statusCode": 200,
"body": "Hello AWS"
}

Lambda invokes this method first.


7. Explain Event Object

Answer

The event parameter contains input data.

Example S3 Event:

{
"Records": [
{
"s3": {
"bucket": {
"name": "mybucket"
},
"object": {
"key": "file.csv"
}
}
}
]
}

8. Explain Context Object

Answer

Context provides runtime information.

Example:

context.function_name
context.memory_limit_in_mb
context.aws_request_id
context.remaining_time_in_millis()

Used for logging and monitoring.


9. What is Cold Start?

Answer

Cold start occurs when Lambda creates a new execution environment.

Steps:

Allocate Container
Load Runtime
Initialize Code
Execute Function

This introduces startup latency.


10. What causes Lambda Cold Starts?

Answer

Factors:

  • First invocation
  • Inactive function
  • Large deployment package
  • VPC attachment
  • Large libraries

11. How to Reduce Cold Starts?

Answer

Methods:

Provisioned Concurrency

Keeps environments warm.

Minimize Package Size

Remove unnecessary libraries.

Use Layers

Separate dependencies.

Avoid Large Initialization

Move logic inside handler.

Use Lightweight Runtime

Node.js and Python start faster than Java.


12. What is Provisioned Concurrency?

Answer

Provisioned Concurrency keeps Lambda instances pre-initialized.

Benefits:

  • Near-zero cold starts
  • Better API response times

Example:

Provisioned Concurrency = 50

50 environments remain ready.


13. What is Reserved Concurrency?

Answer

Reserved Concurrency guarantees capacity.

Example:

Reserved Concurrency = 100

Lambda can use maximum 100 concurrent executions.

Benefits:

  • Prevents resource starvation
  • Controls scaling

14. Difference Between Reserved and Provisioned Concurrency

FeatureReservedProvisioned
Limits Max ExecutionYesNo
Prevents Cold StartNoYes
Guarantees CapacityYesYes
Additional CostNoYes

15. What is Lambda Scaling?

Answer

Lambda automatically scales.

Example:

1 Request → 1 Instance

1000 Requests →
1000 Concurrent Instances

No manual scaling required.


16. What is Lambda Timeout?

Answer

Maximum execution duration.

Range:

1 second – 15 minutes

Example:

Timeout = 300 seconds

After timeout Lambda stops execution.


17. What is Lambda Memory Allocation?

Answer

Memory range:

128 MB to 10,240 MB

Increasing memory also increases:

  • CPU
  • Network throughput

18. How do you optimize Lambda performance?

Answer

Methods:

  • Increase memory
  • Reduce package size
  • Reuse connections
  • Use Provisioned Concurrency
  • Cache SDK clients
  • Optimize code

19. What is Lambda Layer?

Answer

Layers contain reusable dependencies.

Example:

Layer:
pandas
numpy
boto3 extension

Multiple Lambdas can share same layer.

Benefits:

  • Smaller deployment packages
  • Reusability

20. What are Environment Variables?

Answer

Store configuration outside code.

Example:

import os

table=os.environ['TABLE_NAME']

Good for:

  • Bucket names
  • API URLs
  • Configuration values

21. Can Lambda access RDS?

Answer

Yes.

Methods:

  • Direct connection
  • RDS Proxy

Best Practice:

Use RDS Proxy to avoid connection exhaustion.


22. What is RDS Proxy?

Answer

RDS Proxy pools database connections.

Benefits:

  • Better scalability
  • Lower connection overhead
  • Improved availability

Architecture:

Lambda

RDS Proxy

Aurora/MySQL/Postgres

23. Can Lambda run inside VPC?

Answer

Yes.

Use cases:

  • Access RDS
  • Access private resources

Requires:

  • Subnets
  • Security Groups

24. Draw Lambda VPC Architecture

Internet

API Gateway

Lambda

Private Subnet

RDS

25. What are Lambda Destinations?

Answer

Send execution results to:

Success:

  • SNS
  • SQS
  • EventBridge
  • Lambda

Failure:

  • SNS
  • SQS
  • EventBridge

Useful for asynchronous workflows.


26. Difference Between SQS and Lambda

SQSLambda
QueueCompute
Stores MessagesProcesses Messages
DurableStateless
Pull ModelEvent-driven

27. How Lambda works with SQS?

Answer

Flow:

Producer

SQS Queue

Lambda

Database

Lambda polls queue automatically.


28. How Lambda works with SNS?

Answer

Flow:

SNS Topic

Lambda

Email/SMS/DB

SNS pushes message to Lambda.


29. Lambda vs EC2

FeatureLambdaEC2
Server ManagementNoYes
ScalingAutomaticManual
PricingPer RequestRunning Time
Max Runtime15 MinUnlimited
OS AccessNoYes

30. Lambda vs ECS

LambdaECS
Event DrivenContainer Based
Short RunningLong Running
ServerlessManaged Containers

31. Lambda vs Fargate

LambdaFargate
Max 15 MinutesNo Limit
Event DrivenContainer Workloads
No Container RequiredContainers Required

32. Explain Lambda Pricing

Charges

  1. Requests
Per 1 million requests
  1. Compute Duration
GB-Seconds

Formula:

Memory × Execution Time

33. What is Lambda Execution Role?

Answer

IAM role assumed by Lambda.

Example Permissions:

{
"Effect":"Allow",
"Action":["s3:GetObject"],
"Resource":"*"
}

34. What is Least Privilege in Lambda?

Answer

Grant only required permissions.

Bad:

"s3:*"

Good:

"s3:GetObject"

35. How do you monitor Lambda?

Answer

Using:

  • Amazon CloudWatch Logs
  • Metrics
  • Alarms
  • X-Ray
  • CloudTrail

Metrics:

  • Invocations
  • Errors
  • Duration
  • Throttles
  • ConcurrentExecutions

36. What is Lambda Throttling?

Answer

Occurs when concurrency limit is reached.

Example:

Account Limit = 1000
Requests = 2000

Remaining requests throttled.


37. What is Dead Letter Queue (DLQ)?

Answer

Stores failed events.

Supported:

  • SQS
  • SNS

Flow:

Lambda Failure

DLQ

Reprocess

38. Explain Lambda Retry Mechanism

Async Invocation

Retries:

2 additional retries

SQS

Retries based on queue visibility timeout.


39. What is Lambda Versioning?

Answer

Versions create immutable snapshots.

Example:

Version 1
Version 2
Version 3

Useful for rollback.


40. What are Lambda Aliases?

Answer

Pointers to versions.

Example:

DEV → Version 2
TEST → Version 5
PROD → Version 10

41. What is Canary Deployment in Lambda?

Answer

Traffic split between versions.

Example:

90% → Version 10
10% → Version 11

Used for safe deployments.


42. Explain Lambda Security Best Practices

Answer

  • Least privilege IAM
  • Encrypt environment variables
  • Use KMS
  • Enable CloudTrail
  • Use VPC where needed
  • Store secrets in Secrets Manager
  • Enable logging

43. How does Lambda integrate with API Gateway?

Answer

Architecture:

Client

API Gateway

Lambda

DynamoDB

Used to build serverless APIs.


44. Real-Time Scenario: S3 File Processing

Question

Design a file processing system.

Answer

CSV Upload

S3

Lambda

Validate Data

DynamoDB

Benefits:

  • Fully serverless
  • Auto scaling

45. Real-Time Scenario: Data Engineering Pipeline

Answer

S3 Landing

Lambda

Trigger Glue

Transform

Redshift

Common interview architecture.


46. Real-Time Scenario: Event-Driven Architecture

Answer

Application

SNS

Lambda

SQS

Lambda

Database

Decoupled architecture.


47. How would you process 10 million files using Lambda?

Answer

  • Upload files to S3
  • Trigger Lambda
  • Use SQS buffering
  • Configure concurrency
  • Use Step Functions for orchestration
  • Store failures in DLQ

48. How do you invoke Lambda using Boto3?

import boto3

client = boto3.client('lambda')

response = client.invoke(
FunctionName='my-function',
InvocationType='RequestResponse'
)

49. How do you trigger Lambda from EventBridge?

EventBridge Rule

Lambda

Process Event

Use cases:

  • Scheduling
  • Monitoring
  • Automation

50. Senior-Level Interview Question

Q: A Lambda function processing SQS messages is timing out and creating duplicates. How would you solve it?

Answer

  1. Increase timeout.
  2. Increase memory.
  3. Optimize code.
  4. Configure visibility timeout > Lambda timeout.
  5. Use idempotency keys.
  6. Send failures to DLQ.
  7. Monitor CloudWatch metrics.
  8. Use batch processing.

Expected senior answer: Discuss timeout, visibility timeout, retries, duplicate handling, DLQ, idempotency, and observability together.


Top 20 AWS Lambda Interview Questions Asked Most Frequently

  1. What is AWS Lambda?
  2. Explain serverless architecture.
  3. What is a Lambda handler?
  4. What are cold starts?
  5. How do you reduce cold starts?
  6. Reserved vs Provisioned Concurrency?
  7. Lambda vs EC2?
  8. Lambda vs ECS vs Fargate?
  9. How Lambda scales?
  10. Lambda pricing?
  11. Lambda execution role?
  12. Lambda layers?
  13. Lambda environment variables?
  14. Lambda inside VPC?
  15. Lambda with RDS?
  16. RDS Proxy?
  17. Lambda monitoring?
  18. DLQ vs Retry?
  19. Lambda versioning and aliases?
  20. Design a large-scale event-driven architecture using Lambda.

For senior AWS Data Engineer, Cloud Engineer, Solutions Architect, and AI Engineer interviews in the U.S., mastery of Lambda integrations with S3, SQS, SNS, EventBridge, Glue, Step Functions, DynamoDB, RDS, Redshift, Bedrock, and SageMaker is typically expected.

AWS Lambda is AWS’s serverless compute service that runs code in response to events without provisioning or managing servers. You pay only for the compute time consumed (per millisecond). It automatically scales, handles high availability, and integrates deeply with other AWS services.

Basic Interview Questions

1. What is AWS Lambda and how does it work? AWS Lambda is a serverless computing service that executes code in response to triggers (events) like S3 uploads, DynamoDB changes, API Gateway requests, or scheduled events. You upload code as a deployment package (ZIP or container image). Lambda manages the underlying infrastructure, scaling, and execution environments. When invoked, Lambda runs the code in an isolated execution environment and returns the result.

2. What are the key components of a Lambda function?

  • Handler: Entry point method (e.g., lambda_handler(event, context) in Python).
  • Execution role: IAM role granting permissions to access other AWS services.
  • Runtime: Language environment (e.g., Python, Node.js).
  • Event: JSON input from the trigger.
  • Layers: Reusable code/dependencies.
  • Environment variables: For configuration.
  • Versions & Aliases: For deployment management.

3. Which programming languages/runtimes does AWS Lambda support? Native support for Python, Node.js, Java, .NET (C#), Go, Ruby, PowerShell. Custom runtimes are available for others (e.g., via provided.al2023). Choose based on performance needs, ecosystem, and team expertise.

4. What is a cold start vs. warm start in Lambda?

  • Cold start: New execution environment created (download code, initialize runtime, run init code). Adds latency (hundreds of ms to seconds, worse for Java/.NET or large packages).
  • Warm start: Reuses existing environment (faster). Lambda keeps environments for a while after execution.

5. What are triggers (event sources) for Lambda? Synchronous (API Gateway, Application Load Balancer), asynchronous (S3, SNS, SES), and poll-based (SQS, DynamoDB Streams, Kinesis via event source mappings). Triggers can be configured in the console, SAM, or CDK.

6. What are the main limitations of AWS Lambda?

  • Max execution time: 15 minutes (900 seconds).
  • Deployment package: 50 MB (ZIP), 250 MB (uncompressed) or use layers/container images.
  • Ephemeral storage (/tmp): Up to 10 GB.
  • Memory: 128 MB to 10,240 MB (CPU scales proportionally).
  • Concurrency limits (account/region defaults; can request increases).
  • Stateless by design; no long-running persistent connections without care.
  • No direct inbound network (use VPC if needed, but adds latency).

7. How does pricing work? Pay per request + duration (billed in 1 ms increments after the first). Free tier available. Duration cost depends on memory allocated. No charge when idle.

Intermediate Questions

8. Explain Lambda execution environment lifecycle and reuse. Lambda creates a secure, isolated environment with runtime. After execution, it reuses it for subsequent invocations (warm starts) to improve performance. Initialize SDK clients, DB connections, and load heavy libraries outside the handler. Avoid storing user data in global scope to prevent leaks.

9. How do you handle state in serverless/Lambda? Lambda is stateless. Use external services: DynamoDB, S3, RDS, ElastiCache, or EFS for shared storage. For workflows, use Step Functions. Pass state via events or databases.

10. What are Lambda Layers and when to use them? Layers package libraries, custom runtimes, or dependencies separately (up to 5 per function). Useful for sharing code across functions, reducing deployment package size, and separating runtime dependencies from business logic.

11. How does concurrency and scaling work in Lambda? Lambda scales automatically by creating new environments (up to ~1,000 concurrent executions per region by default; burst then linear). Use reserved concurrency to cap a function, provisioned concurrency to keep environments warm (reduces cold starts, extra cost). Account-level limits apply.

12. Explain invocation types (synchronous vs. asynchronous).

  • Synchronous: Caller waits for response (e.g., API Gateway). Errors returned immediately.
  • Asynchronous: Fire-and-forget; Lambda retries up to 2 times on failure. Use DLQ (Dead Letter Queue) or destinations for failed events.
  • Event Source Mapping: For streams/queues (batching supported).

13. How do you optimize cold starts?

  • Use Provisioned Concurrency.
  • Keep functions small/lightweight.
  • Choose faster languages (Node.js/Python over Java).
  • Initialize outside handler.
  • Use SnapStart (for Java).
  • Warm-up with scheduled invocations (carefully).
  • Optimize package size and dependencies.

14. What is the execution role and resource-based policies? Execution role (IAM role assumed by Lambda) grants outbound permissions (least privilege). Resource-based policy on the function grants invoke permissions to services/users.

Advanced & Scenario-Based Questions

15. How would you process files uploaded to S3 using Lambda? Configure S3 event notification (ObjectCreated) as trigger. Lambda downloads/ processes the object (use Boto3/AWS SDK), stores results in another S3 bucket or DynamoDB. Handle large files with Step Functions or S3 Batch. Make idempotent.

16. How do you secure Lambda functions?

  • Least privilege IAM roles.
  • Encrypt environment variables with KMS.
  • Use VPC for private resources (with care for latency).
  • Enable code signing.
  • Monitor with CloudTrail, GuardDuty.
  • Use WAF with API Gateway.
  • Avoid hard-coded secrets.

17. Explain error handling, retries, and DLQs. Asynchronous invocations retry twice. Configure DLQ (SQS/SNS) or On-Failure destinations. Use try/except in code, structured logging, and X-Ray for tracing. Make functions idempotent.

18. How does Lambda integrate with API Gateway? API Gateway acts as a front-end: proxies HTTP requests to Lambda (synchronous). Handles auth (Cognito, IAM, API keys), throttling, caching, CORS. Lambda processes and returns response. Use REST/HTTP APIs.

19. What are best practices for Lambda code and configuration?

  • Stateless, idempotent code.
  • Initialize outside handler.
  • Use environment variables.
  • Structured JSON logging + CloudWatch/EMF.
  • Performance test memory settings (higher memory = more CPU).
  • Use Powertools for AWS Lambda (logging, tracing, metrics).
  • Versioning, aliases, canary deployments.
  • Avoid recursion.

20. How do you monitor, troubleshoot, and optimize Lambda?

  • Metrics: CloudWatch (invocations, errors, duration, throttles).
  • Logs: CloudWatch Logs.
  • Tracing: X-Ray.
  • Alarms on high duration/errors.
  • Use Lambda Power Tuning for memory optimization.
  • Check throttles, concurrency, VPC issues, dependencies.

21. Scenario: Handling database connections in Lambda. Initialize connections outside handler (reuse). Use RDS Proxy for relational DBs to manage connection pooling. For DynamoDB, use SDK clients (reused). Timeout management important.

22. What is Lambda@Edge and when to use it? Runs Lambda closer to users at CloudFront edge locations for low-latency (e.g., personalization, auth, A/B testing, SEO). Limited features vs. regional Lambda.

23. How to deploy and manage Lambda in production (CI/CD)? Use AWS SAM, Serverless Framework, or CDK/Terraform. AWS CodePipeline + CodeBuild for CI/CD. Blue/green or canary via aliases. Infrastructure as Code.

24. Compare Lambda with EC2, ECS/Fargate, or Step Functions.

  • Lambda: Event-driven, max 15 min, simplest.
  • EC2: Full control, always-on.
  • Fargate: Containers, longer tasks.
  • Step Functions: Orchestration of multiple Lambdas/workflows with state.

25. Advanced: How to handle large-scale or long-running workloads? Split into smaller functions + Step Functions. Use SQS for queuing. Container images for larger packages. For >15 min, use ECS or Batch. Provisioned Concurrency or Graviton for cost/performance.

Additional Topics to Prepare

  • SAM (Serverless Application Model): YAML-based IaC for Lambda apps.
  • Destinations (success/failure).
  • SnapStart, Graviton2/ARM processors (better price/performance).
  • Cost optimization: Right-size memory, delete unused functions, use Savings Plans.
  • VPC integration trade-offs (cold starts, ENIs).
  • Idempotency patterns.
  • Troubleshooting common issues (timeouts, permissions, throttling).

Practice with hands-on labs (AWS Free Tier), build small projects (e.g., API backend, S3 processor), and review official docs. Focus on architecture diagrams and real-world trade-offs for senior roles. Good luck!

Preparing for an AWS Lambda interview can feel overwhelming given how many services it touches, but most interviews focus on a few key patterns: event sources, scaling behavior, error handling, and real-world architecture decisions.

Below is a comprehensive guide organized by topic, starting with fundamentals and moving into the scenario-based questions you are most likely to face.


🧱 Part 1: Fundamentals & Core Concepts

These questions establish your baseline understanding of what Lambda is and how it works.

1. What is AWS Lambda, and why is it considered “serverless”?

Answer: AWS Lambda is a Function-as-a-Service (FaaS) compute service that lets you run code without provisioning or managing servers. It is “serverless” because AWS handles all the infrastructure management, including:

  • Auto-scaling: Automatically scales from zero to thousands of concurrent executions.
  • High availability: Runs across multiple Availability Zones (AZs).
  • Maintenance: OS patching, monitoring, and logging are managed by AWS.
  • Pricing: You pay only for the compute time you consume (per millisecond) and the number of requests .

2. What are the key limitations of AWS Lambda?

It is crucial to know the constraints to design effective systems.

  • Execution Timeout: Max 15 minutes (900 seconds).
  • Memory: 128 MB to 10,240 MB (10 GB).
  • Ephemeral Disk (/tmp): 512 MB to 10 GB (as of 2025) for temporary storage.
  • Deployment Package: 50 MB (zipped, direct upload) or 250 MB (using layers).
  • Concurrency: Default account limit is 1,000 concurrent executions per region (adjustable via quota increase) .

3. Can you explain the difference between Synchronous and Asynchronous Invocation?

FeatureSynchronous InvocationAsynchronous Invocation
How it worksThe caller waits for the function to finish and returns the result.Lambda queues the event and returns a success message immediately.
RetriesNo built-in retries (handled by caller).Built-in retries (2 attempts by default) with exponential backoff.
Use CaseAPIs (API Gateway), ALB, Cognito triggers.S3 Events, SNS, EventBridge.
Error HandlingReturns error to caller instantly.Can send failed events to a Dead Letter Queue (DLQ) or On-Failure Destination .

⚡ Part 2: Performance & Concurrency

These are the most common “gotcha” questions regarding speed and scale.

4. What is a “Cold Start” and how do you mitigate it?

Answer: A cold start occurs when Lambda initializes a new execution environment (downloading code, booting the runtime). This adds latency (often 100ms–1s) before your code runs.

Mitigation Strategies:

  • Provisioned Concurrency: Keep a set number of execution environments “warm” and ready to respond instantly (best for latency-critical APIs) .
  • Use lighter languages: Python, Node.js, and Go have faster cold starts than Java or C#.
  • Reduce package size: Minimize dependencies and use Lambda Layers wisely.
  • Keep functions warm: Schedule a CloudWatch Event to ping the function every 5 minutes (cheaper, but less reliable).

5. How does Lambda handle scaling?

Answer: Lambda scales horizontally. For a given function, when traffic increases, Lambda spins up new independent instances of that function to handle the load.

  • Standard scaling: Up to 1,000 concurrent executions in the first minute (then up to 500 per minute after that, depending on region).
  • Reserved Concurrency: Sets a hard limit for a specific function to prevent it from consuming all the account’s concurrency .
  • Unreserved Concurrency: The remaining pool shared by functions without reserved settings.

🔗 Part 3: Integrations & Architecture

These questions test your ability to design systems.

6. How would you design an API backend using API Gateway and Lambda?

Answer:

  1. Trigger: Define a REST or HTTP API in API Gateway.
  2. Integration: Point specific routes (e.g., GET /users/{id}) to a Lambda function.
  3. Processing: Lambda parses the incoming event, interacts with backend resources (DynamoDB, RDS, etc.), and constructs a response.
  4. Return: The function returns a map containing statusCodeheaders, and body (as a JSON string).

“We use this pattern to create scalable, stateless backends where API Gateway handles auth, throttling, and request transformation before handing off to Lambda for business logic.” .

7. How do you process a file uploaded to S3 using Lambda?

Answer:

  1. Event Source: Configure the S3 bucket to send an event notification on s3:ObjectCreated:*.
  2. Trigger: This event invokes the Lambda function asynchronously.
  3. Processing: The Lambda event contains the bucket name and object key. The function downloads the object, processes it (e.g., resizing an image using Pillow), and optionally saves the output back to S3.
  4. Failure: If the function fails, Lambda retries twice; after that, the event goes to a Dead Letter Queue (SQS or SNS) .

8. Can one Lambda function invoke another? Is that best practice?

Answer: “Yes, it is technically possible using the AWS SDK, but it is generally considered an anti-pattern. Direct invocation creates tight coupling and can lead to deep recursion or timeout issues.

Best Practice: For complex workflows involving multiple functions, use AWS Step Functions. For simple chaining, emit an event to SNS/EventBridge and have the second Lambda subscribe to that topic.” .


⚠️ Part 4: Resilience & Error Handling

Real-world systems fail; interviewers want to see you plan for it.

9. How do you handle partial failures when Lambda reads from a Stream (Kinesis/DynamoDB)?

Answer: Unlike SQS with individual message deletion, streams process in batches. If your Lambda fails to process even one record in a batch, the entire batch is returned to the stream and reprocessed.

Strategies:

  • Batch Window: Set a small batch window (e.g., 10 seconds) to reduce the number of records per batch.
  • Split-on-Failure: Attempt to identify the bad record, log it separately to a DLQ, and discard it so the rest of the batch can advance.
  • On-Failure Destination: Route failed batches to an SQS queue for manual inspection .

10. Explain Dead Letter Queues (DLQ) and Destinations.

FeatureDLQ (Legacy)Destinations (Modern)
ServiceOnly SQS or SNS.SQS, SNS, EventBridge, Lambda.
Invocation TypeAsynchronous only.Asynchronous AND Stream (Kinesis/DDB).
PayloadRaw Event.Structured JSON (includes error details).

I configure On-Failure Destinations to send failed events to an SQS queue. This decouples error handling and allows another service to process the dead letter later without blocking the main flow.” .


🗂️ Part 5: Security & VPC

11. How do you access a database in a private VPC (like RDS) from Lambda?

Answer:

  1. VPC Configuration: Attach the Lambda function to the private subnets of the VPC.
  2. Elastic Network Interface (ENI): Lambda creates an ENI in your VPC (this used to cause cold starts, but AWS has improved this).
  3. Security Groups: Configure the database’s Security Group to allow inbound traffic from the Lambda’s Security Group.
  4. RDS Proxy (Best Practice): I would highly recommend using RDS Proxy between Lambda and the database to manage connection pooling. Without it, a sudden spike in Lambda instances could open thousands of database connections and exhaust the DB’s memory .

📊 Part 6: Deployment & Management

12. How do you manage infrastructure and deployment for Lambda?

Answer: “We use Infrastructure as Code (IaC) exclusively. I prefer AWS SAM (Serverless Application Model) or AWS CDK because they have high-level abstractions specifically for Lambda (like Function and Api constructs).

Workflow:

  1. Write code and template.yaml (SAM).
  2. Build: sam build
  3. Deploy: sam deploy --guided (which creates a CloudFormation stack).
    This ensures versioning, rollbacks, and consistency across environments (dev/staging/prod).” .

💡 Final Tips for the Interview

  1. Know your limits: Memory (10GB), Time (15 min), Package Size (250 MB).
  2. Differentiate invocation types: Be able to explain why an S3 trigger retries but an API call does not.
  3. Mention Monitoring: Always bring up CloudWatch Logs (for logs) and AWS X-Ray (for tracing) when asked about debugging or performance.
  4. State the trade-offs: If asked “Why Lambda?” also mention when not to use it (e.g., long-running tasks, predictable high-traffic 24/7 workloads where EC2/container might be cheaper) .

🤞 Sign up for our newsletter!

We don’t spam! Read more in our privacy policy

Scroll to Top