Serverless Best Practices

Each function should do only one thing

It’s about function error and scaling isolation.

Functions don’t call other functions

Functions calling other functions is an anti-pattern.

Use as few libraries in your functions as possible (preferably zero)

This one seems obvious to me.

Avoid using connection based services e.g. RDBMS

Just don’t unless you have to.

One function per route (if using HTTP)

Avoid using the single function proxy where possible. It doesn’t scale well and doesn’t help isolate issues. There are occasions where you can avoid this, e.g. where the functionality of a series of routes are tied strictly to a single table and it’s very much decoupled from the rest of the application, but that is an edge case in most applications I’ve worked in.

Learn to use messages and queues (async FTW)

Serverless applications tend to work best when the application is asynchronous. This isn’t straight forward for web applications where the tendency is to do request-response and lots of querying.

Data flows, not data lakes

In a serverless system, your data flows through your system. It can end up in a data lake, but the likelihood is that while it’s in your serverless system it is in some sort of flow. So treat all data like it is in motion, not at rest at any point.

Just coding for scale is a mistake, you have to consider how it scales

It is very easy to create your first serverless application, and watch it scale. If you don’t understand what you’ve done though, you can easily fall into the trap that you can with every other auto-scaling solution.


There are lots more things I could have put in here and this is my opinion about the things that I have to explain most to people when I talk to them.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Paul Johnston

Paul Johnston

ServerlessDays CoFounder (Jeff), ex AWS Serverless Snr DA, experienced CTO/Interim, Startups, Entrepreneur, Techie, Geek and Christian