Technical
Lambda Cold Starts: What Actually Helps (And What's Theater)
Every time someone mentions Lambda cold starts, someone else says 'provisioned concurrency.' I tried it. It helped, but it also added cost. Before paying for warm containers, try the cheaper fixes.
Measure First
I run aws logs filter-log-events and grep for Init Duration. That is the cold start cost. On my Python FastAPI Lambda it was 1.2 seconds. On the Node version it was 400ms. Same business logic. Language and dependencies dominate.
# Before: import everything at module scope
import boto3
import pandas as pd # 800ms init
import heavy_module # 300ms init
# After: lazy import inside handler
def handler(event, context):
import pandas as pd
import heavy_module
# business logicLazy imports cut my cold start from 1.2s to 400ms without provisioned concurrency. The imports still run eventually, but warm invocations skip them entirely.
The Ladder I Walk
- Lazy imports for anything over 100ms to load
- Drop dependencies I do not actually need
- Move to ARM (Graviton) for 20-30% faster starts
- Only then consider provisioned concurrency
Each step is free or nearly free. Provisioned concurrency costs real money per hour per function. Earn the right to spend by exhausting the free levers first.
When Provisioned Wins
If your function is user-facing and latency-sensitive under 200ms, provisioned is the answer. Otherwise the cheaper fixes usually close the gap. Read the Lambda performance optimization docs before reaching for the paid option.
RELATED READING
The Consulting Shift I Am Making In Year Two
After a year of writing and building, my consulting practice is changing shape. Shorter engagements. Sharper outcomes.
ReadThe Frontend Shift: Shipping Less JavaScript In Year Two
A year ago I reached for Next.js for everything. This year I often reach for nothing.
ReadThe Serverless Lesson I Would Write On A Sticky Note
After a year of shipping serverless projects, one rule explains most of the wins and all of the losses.
Read