SNS fan-out

An application design will sometimes require us to take one message and deliver it to multiple different groups of systems for processing. The SNS service is able to take one message and deliver it to multiple SQS targets. This allows us to extend the functionality of the SQS service from a standard one-to-one approach to a service that can provide a one-to-many delivery. In this example, one message is sent to three different backends and each can perform the task in a different way.

For example, whenever a new image is posted to our website, we need to format it into several standard sizes: a thumbnail, a mobile size, and a standard web-optimized size. We can send the message of the image's upload to the SNS topic, which in turn pushes the message into the three different SQS queues where the respective workers are listening and will perform the task of creating the thumbnail and the web-optimized and the mobile-optimized images in parallel:

We can also use the fan-out approach to notify completely different services of an event that happened, for example, if we have an application where an event or message needs to be processed in several ways by several completely different components. In this example, the message being sent to the SNS service is processed in three different ways:

  • The SQS queue takes the message for the workers to process the content.
  • The Lambda function reads the metadata from the message.
  • The HTTP endpoint records the message in an archive.

The following setup of an SNS topic, where an HTTP endpoint, a Lambda, and an SQS service are subscribed, will allow us to process the message, record its metadata, and archive it in parallel:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.172.132