Technical
Lambda Layers: When They Help and When They Hurt
Lambda layers are one of those AWS features that sound great in a talk and feel terrible in practice. I used them heavily for a few months, then removed most of them. Here is what I learned about when a layer is pulling its weight and when it is just adding ceremony.
What Lambda Layers Do
A layer is a zip of code or dependencies that can be shared across multiple Lambda functions. Instead of bundling the same library into every deployment, you publish it once as a layer and reference it from each function. Sounds efficient. In practice, it adds a moving part.
Where They Actually Help
Layers are worth it in exactly two situations:
- Large shared dependencies: if ten functions use the same 50MB library, a layer saves deployment time
- Environment-specific binaries: pre-compiled native code that is hard to ship with your app
That is it. Those two cases genuinely benefit from the separation.
Where They Hurt
Everywhere else:
- Versioning nightmare: which layer version is deployed where, and when do you bump?
- Local development friction: simulating the layer locally is always broken
- Debugging pain: your traceback points inside a layer you did not write
- Deployment coupling: a layer change now affects every function that uses it
Most of my early layers were small Python helpers I had extracted from a single repo. Shared business logic across services. A common auth helper. In every case, the layer was more trouble than just vendoring the code into each function. Especially with modern build tooling that does not care how much code you ship.
The Rule I Use Now
Is the dependency large (>10MB) AND shared (>3 functions)?
YES -> consider a layer
NO -> bundle it with the functionThat rule eliminates about 90% of the layers I used to have. The ones that remain genuinely save deployment time and are stable enough to be worth the ceremony. Everything else is simpler as a direct dependency.
What Replaced Them
Most of what I was using layers for is better served by a small internal utility package, vendored into each function via a build step. Same code reuse, no AWS-specific complexity, works identically in local development and production.
The AWS Lambda layers documentation explains the full model if you do need one.
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