Publisher/subscriber model

In the pub/sub model, when an event is published, a notification is sent to all subscribers, and each subscriber can take the necessary action as per their requirements of data processing. Let's take an example of a photo studio application, which enriches a photo with different filters and sends a notification to the user. The following architecture depicts a pub/sub model:

 

Photo studio application pub/sub-event-driven architecture

In the preceding diagram, you will notice the following things:

  1. The user first uploads the picture to an Amazon S3 bucket using a web/mobile application.
  2. The Amazon S3 bucket then sends a notification to Amazon Simple Notification Service (SNS). Amazon SNS is a message topic with the following subscribers:
    1. Here, the first subscriber is using the email service, and as soon as the photo upload is complete, an email is sent to the user.
    2. The second subscriber is using Amazon SQS queue, which gets the message from the Amazon SNS topic and applies various filters in code written in AWS Lambda to improve the image quality.
    3. The third subscriber is using the direct AWS Lambda function, which creates the image thumbnail.

In this architecture, Amazon S3 publishes the message to the SNS topic as a producer which is consumed by multiple subscribers. Additionally, as soon as the message comes to SQS, it triggers an event for the Lambda function to process images.

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

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