A Few Serverless “Rules of Thumb”

#1 Zero or One data transformations per nano-function

When building your nano-functions, allow for either zero or one data transformation within the function.

Any more than that, and you risk problems with your data should there be a problem in any subsequent data transformations.

While you can avoid most problems by handling errors in the function, the best thing to do is do a transformation, and if a second is required push it to a later point in the flow where you can resend the event if needed.

Also, it allows you to use the right data source for the right need. You don’t always have to use (managed) RDBMs or NoSQL solutions exclusively.

If you are used to using a server, then you are used to having access to a framework which usually means a lot of libraries/plugins/middleware of some sort.

The purpose of a nano-function is to be small, partly (but not completely) so it is fast loading.

If you end up putting a framework into a nano-function (a lot of blogs around AWS Lambda suggest embedding express in your function!) then you end up with a bunch of code that will never be executed being included for no reason at all

The likelihood is that you either are over-engineering the function or not fully understanding what libraries you could use.

Best thing to do, start with zero libraries/imports and work upwards when you need it. Not the other way around.

Normally, you have your access to the server and can find out if things go wrong by reviewing logs. Not so with serverless.

Make sure that however you develop your events and nano-functions you are fully aware of your possible error points and capture the right data to give you the right information.

Oh and too much logging is worse than not enough. A stack trace on error is actually often all you need.

Written by

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

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