7 ways to reduce AWS Lambda cold starts: From simple to advanced

Lambda cold starts are when a new container spins up and loads your code. First invocation takes 5+ seconds. Second invocation (warm) takes 100ms. The gap is the problem.

1. Reduce package size

Big packages = slow downloads and init. Compress dependencies. Remove test files. Use Lambda Layers. Drop 50-70% is normal.

2. Choose the right memory

More memory = more CPU = faster execution. Counter-intuitive but true. 512MB might finish slower than 1024MB despite higher per-second cost.

Test with Lambda Power Tuning. Find the sweet spot.

3. Reduce initialization code

Global imports load at function start. Lazy-load inside handler. Only import what's used per invocation.

Remove synchronous I/O in global scope. Move to async handlers.

4. Use appropriate runtimes

Node.js cold starts: ~200-500ms.

Python cold starts: ~300-600ms.

Java cold starts: ~1-3 seconds.

If cold start matters, use Node or Python. Java functions need Provisioned Concurrency or SnapStart.

5. Use arm-based Graviton processors

Graviton functions are 20% cheaper, often slightly faster. If your code works on ARM, use it.

6. Provisioned Concurrency

Keep warm instances always running. No cold start. Pay for always-on capacity (roughly £0.015 per concurrency-hour).

Worth it for customer-facing APIs. Not worth it for background jobs.

7. SnapStart (Java only)

Takes snapshot of initialized JVM. Reuses snapshot instead of starting JVM. Massively faster. Java 11/17 only.

Practical: combine multiple strategies

Reduce package from 85MB to 10MB: saves 1 second.

Increase memory from 256MB to 512MB: saves 0.5 seconds.

Use Graviton: saves 0.2 seconds.

Combined: 1.7 seconds faster cold start. Goes from 5 seconds to 3.3 seconds.

For most applications, good enough.

Where Critical Cloud comes in

Cold start improvements are only valuable if you measure them. Is your cold start actually slow? Which strategy helps most?

We track Lambda cold start times in Datadog. You see what's slow and what's improving.

If Lambda cold starts are unpredictable or you're not sure where time goes, see how Critical Support works.