Chapter 9. Advanced Serverless Architecture

In Chapter 8 we looked at some more advanced aspects of Lambda that are important once you start thinking about productionizing your applications. In this chapter, we continue that theme, looking more broadly at the impact of Lambda on architecture.

Serverless Architecture “Gotchas”

First we look at areas of serverless architecture that might cause you problems if you don’t consider them, and we offer different solutions for addressing these problems depending on your situation.

At-Least-Once Delivery

The Lambda platform guarantees that when an upstream event source triggers a Lambda function, or if another application explicitly calls the Lambda invoke API call, then the corresponding Lambda function will be called. But one thing the platform doesn’t guarantee is how many times the function will be called: “Occasionally, your function may receive the same event multiple times, even if no error occurs.” This is known as “at-least-once delivery,” and it exists due to the fact that the Lambda platform is a distributed system.

The vast majority of the time a Lambda function will be called only once per event. But sometimes, very occasionally (far less than 1% of the time), a Lambda function will be called multiple times. Why is this a problem? And how do you deal with this behavior? Let’s take a look.

Example: Lambda “cron jobs”

If you’ve been developing software in industry long enough, you’ve probably come across a server host that ...

Get Programming AWS Lambda now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.