A monolithic backend on EC2 was struggling with burst traffic — during peak hours it fell over, and during off-hours it sat idle burning money on unused capacity.
Decomposed the monolith into purpose-built Lambda functions, wired API Gateway routing, implemented DLQ for failed events, and optimized cold starts for critical paths.
Heavy async operations moved to SQS-triggered Lambdas. API stays responsive — requests are accepted immediately, processing happens asynchronously. Dead-letter queues catch and preserve failed events.
functions:
processOrder:
handler: src/orders/process.handler
events:
- sqs:
arn: !GetAtt OrderQueue.Arn
batchSize: 10
functionResponseType: ReportBatchItemFailures
resources:
Resources:
OrderQueue:
Type: AWS::SQS::Queue
Properties:
RedrivePolicy:
deadLetterTargetArn: !GetAtt OrderDLQ.Arn
maxReceiveCount: 3Profiled cold start times on critical auth paths — 800ms was unacceptable. Optimized package sizes with webpack tree-shaking, added provisioned concurrency for the top 3 critical functions.
Scaled seamlessly from 0 to 5,000+ RPS during peak. Monthly costs down 65% vs EC2. Zero 503s during traffic spikes.
"The system now costs nothing when idle and handles any spike without pre-planned capacity. Operational overhead dropped to near zero."