⚡ AWS Lambda — DevOps Interview Deep Dive
✅ Part 1 — Core Understanding (Foundation)
✅ Q1 — What is AWS Lambda in practical terms?
Lambda is a serverless compute service where you run code without managing servers. You upload a function and AWS runs it on-demand in response to events. It auto-scales per request and charges per execution time and memory used. It’s best for event-driven and burst workloads, not long-running services.
✅ Q2 — Real production use cases of Lambda (not textbook)?
Real use cases:
- API backends behind API Gateway
- Event processing from S3, SQS, SNS, EventBridge
- Fintech transaction validation hooks
- Async background jobs
- Log processing pipelines
- Scheduled compliance checks
- Lightweight ETL jobs
- Control-plane automation tasks
In fintech — often used for audit triggers, async settlement processing, webhook handlers.
✅ Q3 — When is Lambda better than containers/Kubernetes?
Lambda is better when:
- Traffic is bursty/unpredictable
- Execution is short-lived
- No need for long-running connections
- You want zero infra management
- Scale-to-zero matters
- Ops team is small
Not better when you need steady high throughput or low-latency always-on APIs.
✅ Part 2 — Limits & Hard Constraints (Interview Favorite)
✅ Q4 — Key Lambda limits you must know (production-impacting)
Important limits:
- Max timeout: 15 minutes
- Memory: 128 MB – 10 GB
- Ephemeral storage: /tmp ~ configurable up to 10 GB
- Payload size sync: ~6 MB (API Gateway smaller)
- Concurrency default account limit (soft limit)
- Deployment package size limits
- Init duration affects cold start
Interviewers expect at least timeout + concurrency + memory awareness.
✅ Q5 — Lambda concurrency — how does scaling actually work?
Lambda scales by creating more execution environments. Each concurrent request can get its own instance. There’s account-level concurrency quota. You can set reserved concurrency per function to protect others. Sudden spikes can hit concurrency limits and cause throttling.
✅ Q6 — What happens when concurrency limit is hit?
New invocations get throttled. Behavior depends on trigger:
- API → error to client
- SQS → message stays, retried
- async → retried automatically
Good design includes DLQ or retry strategy.
✅ Part 3 — Cold Starts & Performance
✅ Q7 — What is cold start really?
Cold start = Lambda must create new execution environment before running code. Happens when no warm instance available. Includes container spin-up + runtime init + code load. Affects latency-sensitive APIs.
✅ Q8 — How do you reduce cold start impact?
Methods:
- Provisioned Concurrency
- Smaller package size
- Faster runtimes
- Lazy initialization
- Keep functions warm via traffic
- Avoid heavy init code
For fintech APIs — provisioned concurrency often used.
✅ Part 4 — Lambda Networking Reality
✅ Q9 — Lambda inside VPC — what changes?
Lambda attached to VPC creates ENIs. This adds startup latency and IP consumption. Needs NAT for outbound internet. Many people attach to VPC unnecessarily — increases cold start.
✅ Q10 — When must Lambda be inside VPC?
Only when it needs private resources:
- RDS private endpoint
- internal services
- private Redis
- private APIs
Otherwise keep it outside VPC.
✅ Part 5 — Cost Tradeoffs
✅ Q11 — When is Lambda cheaper?
Cheaper for:
- low or bursty traffic
- short execution time
- scale-to-zero workloads
- cron/async jobs
✅ Q12 — When is Lambda more expensive than containers?
Expensive when:
- high constant throughput
- long execution time
- heavy memory size
- always-on APIs
Steady load → containers cheaper.
✅ Part 6 — Reliability & Failure Patterns
✅ Q13 — Lambda retry behavior — what people get wrong?
Async invocations retry automatically. Sync do not. SQS retries until visibility timeout. Streams retry with batch behavior. Must design idempotency — retries can duplicate work.
✅ Q14 — How do you design idempotent Lambda handlers?
Use request IDs, dedup keys, or DB checks. Never assume single execution. Especially critical in payments/fintech.
✅ Part 7 — Security & Governance
✅ Q15 — Lambda security best practices?
- Least privilege IAM role
- No secrets in env vars without encryption
- Use Secrets Manager
- VPC only if needed
- Code signing if required
- Dependency scanning
✅ Part 8 — When NOT to Use Lambda
✅ Q16 — When should you avoid Lambda?
Avoid when:
- long-running jobs
- streaming servers
- heavy CPU tasks
- ultra-low latency APIs
- WebSocket stateful servers
- large memory datasets
- tight request-response loops