What is AWS Lambda advanced patterns?

Why Interviewers Ask This

Advanced questions like this reveal whether a candidate has internalized AWS / Cloud Computing deeply enough to make architectural decisions. Strong answers demonstrate both breadth and depth of experience.

Answer

Advanced AWS Lambda patterns and optimizations: 1. Provisioned Concurrency: pre-initialize Lambda execution environments to eliminate cold starts. Pay extra for warm instances. Schedule: use Application Auto Scaling to pre-warm before expected traffic. Use for latency-sensitive APIs. 2. Lambda Layers: package shared dependencies (libraries, runtimes) in a layer → add to functions. Up to 5 layers per function. 50MB compressed. Reduces deployment size, enables dependency sharing. 3. Lambda Power Tuning: open-source tool to find optimal memory setting for cost/performance. More memory = more CPU = faster = lower duration billing — often higher memory is cheaper overall. 4. Lambda@Edge / CloudFront Functions: Lambda@Edge runs at CloudFront PoPs (130+ locations), 128MB-10GB, up to 30s timeout. Uses: A/B testing, authentication, dynamic content personalization, URL rewriting, header manipulation. CloudFront Functions: faster (sub-ms), cheaper, limited (2MB code, 2MB memory, no network calls, viewer-only events). 5. Lambda URL: direct HTTPS endpoint for Lambda without API Gateway. Good for simple function-as-API needs. 6. Function URLs with streaming: stream response bytes progressively (useful for long-running AI responses). 7. Dead Letter Queues: async invocation failures → DLQ (SQS or SNS) for manual inspection and retry. 8. Lambda destinations: on success → send result to SQS/SNS/EventBridge/another Lambda; on failure → DLQ alternative, send context. 9. SnapStart (Java): take snapshot after initialization, restore from snapshot on cold start — 10x faster cold starts for Java. 10. Recursive loop detection: Lambda detects recursive invocations (Lambda calling itself via SQS/SNS) — built-in protection. 11. VPC Lambda: enable VPC access for private resources (RDS, ElastiCache) — adds cold start latency; use ENIs; need subnets with NAT Gateway for internet access.

Common Mistake

Many candidates answer correctly but can't explain the 'why'. Always be prepared to justify your answer with a concrete example or use case from your AWS / Cloud Computing experience.