Should I use a single, monolithic Lambda function or multiple Lambda functions with API Gateway?

J.D. Hollis
Jul 16, 2018 · 1 min read

I’ve seen a lot of discussion in various forums on whether it’s better to use a single, monolithic Lambda function (with its own routing logic) or multiple, single-purpose Lambda functions with API Gateway. Arguments in favor of a monolithic function are that it’s easier to manage, more performant, and easier to understand.

I disagree.

Automated tools such as CloudFormation, Terraform, and Serverless make managing one or many functions easy. The issue of Lambda cold starts is a bit overblown. And while a single function may seem conceptually simpler, any developer that needs to work with that function will need to understand more code to safely make changes, even if that code doesn’t directly apply to the task at hand.

I recommend multiple, single-purpose Lambda functions.

Because each function only does one thing, it’s easier to understand and easier to change safely. You’ll also reduce your blast radius when deploying changes. And you’ll have clear metrics on which functions are triggered most often and how much those functions cost your business.

I could go into much more detail on any of these topics — let me know what you’re most interested in via the responses.

If you find my work interesting, sign up for the Statics & Dynamics mailing list so you don’t miss a thing.

Statics & Dynamics

Adventures in cloud architecture

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade