Sending Async Fan-Out Messages Using the Serverless Framework

Lab Steps

lock
Understanding the Structure of the Fan Out Pattern
lock
Initializing a Project Using the Serverless Framework
lock
Building and Deploying a Decoupled Microservice With the Serverless Framework
lock
Testing the Asynchronous Microservice

Ready for the real environment experience?

DifficultyAdvanced
Time Limit1h 15m
Students13
Ratings
5/5
starstarstarstarstar

Description

When designing microservices, one of the most important things to avoid is the bottleneck. One of the most known parts that could cause a bottleneck is the synchronous communications between two different parts. Because of that, designing a microservice that communicates in an asynchronous way could be a winning choice. To do so, you should consider using middleware components such as topics and queues. If you need to send trigger multiple asynchronous parts and don't want to write code for each single invocation, you can consider the fan out pattern. The fan out pattern implements a single topic that will push each received message to multiple queues. That way, by only sending a single message from your code, it will be sent into multiple queues, so multiple functions will be invoked asynchronously.

The Serverless Framework allows you to easily define the resources of an asynchronous microservice, define the triggers (in that case a trigger could be a message in a queue or a message sent to a topic), and define the middleware components that are essential for realizing the asynchronous communication.

In this lab, you will leverage the Serverless Framework to create three serverless functions: one will be invoked synchronously by the user, the other two will be invoked asynchronously from the first one. You will use the Serverless Framework to create the two SQS queues (one for the second function, and the other one for the third function), and an SNS topic where the first function will send the messages to. This topic will realize the fan out pattern by pushing each received message to the two SQS queues.

Learning Objectives

Upon completion of this lab you will be able to:

  • Build and deploy serverless functions and resources using the Serverless Framework
  • Realize an asynchronous communication between different functions following the fan out pattern

Intended Audience

This lab is intended for:

  • Software engineers mainly focused on serverless development
  • Solutions architects that need to build asynchronous microservices

Prerequisites

To get the most from this lab, you should have basic knowledge of the Serverless Framework, SNS, and SQS. To get ready, you can use the following labs:

Environment before
PREVIEW
arrow_forward
Environment after
PREVIEW
About the Author
Students18181
Labs63
Courses2
Learning paths3

Stefano studies Computer Science and is passionate about technology. He loves working with Cloud services and learning all the best practices for them. Google Cloud Platform and Amazon Web Services are the cloud providers he prefers. He is a Google Cloud Certified Associate Cloud Engineer. Node.js is the programming language he always uses to code. When he's not involved in studying or working, Stefano loves riding his motorbike and exploring new places.