Skip to main content

Lambda SnapStart now works with container images

· Do Minh Tuan · Future Pulse 🔮

Lambda SnapStart now works with container images

AWS has extended Lambda SnapStart to container image functions. Until now, if you wanted SnapStart, you were mostly working with zip packages and the 250 MB limit that comes with them. Container images allow up to 10 GB, which is enough for heavy dependencies like machine learning libraries, but they historically paid for that size with slower cold starts. SnapStart is meant to remove the trade.

A cold start is the delay when a serverless function has not run recently and the platform has to create an environment, load the runtime and start your code. For a small function it is a blink. For a container with a large dependency tree it can be seconds, and seconds are visible to a user waiting on a page. That is why teams used to choose between a small package that starts fast and a big image that has everything they need.

How the snapshot works

SnapStart runs your initialization once, takes a snapshot of the memory state of the microVM, and stores it. When a request arrives, Lambda resumes from that snapshot instead of booting from scratch. AWS describes the result as sub-second startup, and for a function that previously spent several seconds loading libraries, that is a meaningful change.

The catch is the word snapshot. Everything that existed in memory at the moment the snapshot was taken comes back with it, including things you might have wanted to be fresh. That is the trap I would put first in any review.

The state leakage problem

If your initialization code generates a random seed, fetches a temporary database token, or assigns a unique request id at module load, that value is captured in the snapshot. Every invocation resumed from that snapshot starts with the same value. For a seed, that can quietly break randomness. For a token, it can mean every user shares one credential until it expires. For an id, it can mean your logs cannot tell requests apart.

The fix is a discipline, not a feature. Put static initialization at the top of the module: importing libraries, creating clients that are safe to reuse, pre-warming connections where the SDK supports it. Put anything user-specific or time-specific inside the handler, so it is computed per invocation. That is good practice anyway. SnapStart makes the consequence of getting it wrong much more obvious.

I would also test the resume path explicitly. Deploy, wait for the function to go cold, invoke it, and check that the values you expect to be fresh are actually fresh. A unit test will not catch this, because the test process does not take a snapshot. It has to be an integration test against the deployed function.

What it changes for a team

The practical win is that the packaging compromise goes away. You can put the ML model, the PDF renderer or the image processing library in the image without accepting a multi-second cold start. That means workloads that used to require an always-on container can move to pay-per-use, which matters for spiky traffic. If your service is busy all day, the saving is smaller. If it gets a burst every morning, serverless becomes a better fit.

The original post cites the familiar claim that a hundred milliseconds of extra latency can cost a noticeable share of conversions, and it pairs that with a claim about cutting AWS bills by a specific percentage. I would treat both as directional. The latency effect is real and well studied in general, but the exact number depends on the product. The bill reduction depends entirely on what you were running before. A team moving from always-on EC2 to Lambda will see a big change. A team already on Lambda will see a smaller one.

Where I would be careful

SnapStart is not a universal switch. It works best for functions where initialization is expensive and the runtime state is safe to reuse. It is a poor fit for code that opens a connection at startup, caches credentials, or depends on randomness at module scope. The documentation lists the constraints, and they are worth reading twice before enabling it across a fleet.

There is also a testing cost that does not appear in the pricing. A team that adopts this without understanding snapshots will spend a week debugging a bug that only appears in production, because the local environment never resumes from a snapshot. The symptom is often bizarre: the same user id for every request, or a random value that is not random. I would budget time for that, and I would write the integration test before turning it on. A short checklist in the repository beats a long document nobody reads.

For a founder in Vietnam running a small team on AWS, this is a useful option when a heavy dependency is forcing you onto containers. It lets you keep the convenience of serverless without the cold start penalty. It is not a reason to move to Lambda if you are happy on a container platform, and it is not a substitute for measuring your actual latency on your own traffic.

What I would watch is how the snapshot behaves across runtime updates and how clearly AWS documents the initialization rules. The feature is good. The footgun is sharp, and the teams that do well with it will be the ones that treat initialization as a design decision rather than a place to put whatever runs first.

Written with AI assistance, reviewed and edited by Do Minh Tuan.