🖥️
Sunil Notebook
Interview Preparation
  • 📒Notebook
    • What is this about ?
  • System Design
    • 💡Key Concepts
      • 🌐Scalability
      • 🌐Latency Vs Throughput
      • 🌐Databases
      • 🌐CAP Theorem
      • 🌐ACID Transactions
      • 🌐Rate limiting
      • 🌐API Design
      • 🌐Strong Vs eventual consistency
      • 🌐Distributed tracing
      • 🌐Synchronous Vs asynchronous Communication
      • 🌐Batch Processing Vs Stream Processing
      • 🌐Fault Tolerance
    • 💎Building Blocks
      • 🔹Message
      • 🔹Cache
      • 🔹Load Balancer Vs API Gateway
    • 🖥️Introduction to system design
    • ⏱️Step By Step Guide
    • ♨️Emerging Technologies in System Design
    • ☑️System design component checklist
      • 🔷Azure
      • 🔶AWS
      • ♦️Google Cloud
    • 🧊LinkedIn feed Design
    • 🏏Scalable Emoji Broadcasting System - Hotstar
    • 💲UPI Payment System Design
    • 📈Stock Broker System Design - Groww
    • 🧑‍🤝‍🧑Designing Instagram's Collaborative Content Creation - Close Friends Only
    • 🌳Vending Machines - Over the air Systems
    • Reference Links
  • DSA
    • Topics
      • Introduction
      • Algorithm analysis
        • Asymptotic Notation
        • Memory
      • Sorting
        • Selection Sort
        • Insertion Sort
        • Merge Sort
        • Quick Sort
        • Quick'3 Sort
        • Shell Sort
        • Shuffle sort
        • Heap Sort
        • Arrays.sort()
        • Key Points
        • Problems
          • Reorder Log files
      • Stacks and Queues
        • Stack Implementations
        • Queue Implementations
        • Priority Queues
        • Problems
          • Dijkstra's two-stack algorithm
      • Binary Search Tree
        • Left Leaning Red Black Tree
          • Java Implementations
        • 2-3 Tree
          • Search Operation - 2-3 Tree
          • Insert Operation - 2-3 Tree
        • Geometric Applications of BST
      • B-Tree
      • Graphs
        • Undirected Graphs
        • Directed Graphs
        • Topological Sort
      • Union Find
        • Dynamic Connectivity
        • Quick Find - Eager Approach
        • Quick Find - Lazy Approach
        • Defects
        • Weighted Quick Union
        • Quick Union + path comparison
        • Amortized Analysis
      • Convex Hull
      • Binary Heaps and Priority Queue
      • Hash Table vs Binary Search Trees
  • Concurrency and Multithreading
    • Introduction
    • Visibility Problem
    • Interview Questions
    • References
      • System design
  • Design Patterns
    • ℹ️Introduction
    • 💠Classification of patterns
    • 1️⃣Structural Design Patterns
      • Adapter Design Pattern
      • Bridge Design Pattern
      • Composite Design Pattern
      • Decorator Design Pattern
      • Facade Design Pattern
      • Flyweight Design Pattern
      • Private Class Data Design Pattern
      • Proxy Design Pattern
    • 2️⃣Behavioral Design Patterns
      • Chain Of Responsibility
      • Command Design Pattern
      • Interpreter Design Pattern
      • Iterator Design Pattern
      • Mediator Design Pattern
      • Memento Design Pattern
      • Null Object Design Pattern
      • Observer Design Pattern
      • State Design Pattern
      • Strategy Design Pattern
      • Template Design Pattern
    • 3️⃣Creational Design Patterns
      • Abstract Factory Design Pattern
      • Builder Design Pattern
      • Factory Method Design Pattern
      • Object Pool Design Pattern
      • Prototype Design Pattern
      • Singleton Design Pattern
    • Java Pass by Value or Pass by Reference
  • Designing Data-Intensive Applications - O'Reilly
    • Read Me
    • 1️⃣Reliable, Scalable, and Maintainable Applications
      • Reliability
      • Scalability
      • Maintainability
      • References
    • 2️⃣Data Models and Query Languages
      • Read me
      • References
    • Miscellaneous
  • Preparation Manual
    • Disclaimer
    • What is it all about?
    • About a bunch of links
    • Before you start preparing
    • Algorithms and Coding
    • Concurrency and Multithreading
    • Programming Language and Fundementals
    • Best Practices and Experience
  • Web Applications
    • Typescript Guidelines
  • Research Papers
    • Research Papers
      • Real-Time Data Infrastructure at Uber
      • Scaling Memcache at Facebook
  • Interview Questions
    • Important links for preparation
    • Google Interview Questions
      • L4
        • Phone Interview Questions
      • L3
        • Interview Questions
      • Phone Screen Questions
  • Miscellaneous
    • 90 Days Preparation Schedule
    • My Preparation for Tech Giants
    • Top Product Based Companies
  • Links
    • Github
    • LinkedIn
Powered by GitBook
On this page
  • Introduction
  • Message Queues
  • Use Cases
  • Publish/Subscribe (Pub/Sub) Systems
  • Use cases
  • Event Streaming Platforms
  • Use Cases
  • Event Routing and Processing
  • Use Cases
  • Stream Processing
  • Use Cases
  • Enterprise Messaging Systems
  • Use Cases
  • Managed Messaging Services
  • Use Cases
  • References

Was this helpful?

Edit on GitHub
  1. System Design
  2. Building Blocks

Message

Introduction

In the modern distributed systems, Asynchronous messaging options are broadly classified into the categories below.

  • Message queues

  • Pub/sub systems

  • Event streaming platforms

  • Event routing and processing services

  • Stream processing services

  • Enterprise messaging systems

  • Managed messaging services

Producer can directly communicate with Consumer, but why do we need intermediate step message broker?

/Response from ChatGPT

  • Decoupling:

    • Independence: Producers and consumers can operate independently without needing to know each other’s specifics. This decoupling allows for easier maintenance and updates since changes in one component do not necessitate changes in the other.

    • Scalability: Producers and consumers can be scaled independently based on their load requirements.

  • Reliability:

    • Message Persistence: Message brokers can persist messages to ensure they are not lost in case of a failure. This is crucial for maintaining data integrity in distributed systems.

    • Retry Mechanisms: Brokers can manage message retries, ensuring that messages are delivered even if the consumer temporarily goes down.

  • Load Balancing:

    • Distributed Load: Brokers can distribute the load among multiple consumers, preventing any single consumer from becoming a bottleneck.

    • Backpressure Handling: Brokers can manage backpressure by queuing messages when the consumer is overwhelmed, thus preventing system crashes due to overload.

  • Flexibility:

    • Message Routing: Brokers can route messages based on various criteria such as content, topic, or headers, allowing complex communication patterns like publish-subscribe, request-reply, and fan-out.

    • Transformation: Some brokers can transform messages, ensuring compatibility between different versions of producers and consumers.

  • Resilience:

    • Fault Tolerance: Brokers often come with built-in fault tolerance, allowing systems to continue operating smoothly even when some components fail.

    • Failover: In case a consumer fails, the broker can redirect messages to another available consumer.

  • Monitoring and Management:

    • Metrics and Logging: Message brokers provide detailed metrics and logging capabilities, allowing for better monitoring and debugging of the system.

    • Throttling: Brokers can throttle message delivery to consumers, preventing system overload.

  • Security:

    • Access Control: Brokers can enforce access control policies, ensuring that only authorized producers and consumers can communicate.

    • Encryption: Brokers can handle message encryption, ensuring data privacy and integrity during transmission.

Let's go through all the services categories.

First let me clarify why there are distinct categories. We can classify messages into two.

  • If the producer expects an action from the consumer, that message is a command.

  • If the message informs the consumer that an action has taken place, then the message is an event.

Understand your requirement clearly and then go for which messaging system to use.

Now lets go through all the categories once and identify what all the different cloud providers are providing.

Message Queues

Message queues allow for decoupled communication between producers and consumers, ensuring reliable message delivery and processing.

Use Cases

Use Case 1: Order Processing System

  • Scenario: An e-commerce platform processes customer orders.

  • Implementation: When a customer places an order, it is placed in a message queue (e.g., Amazon SQS). A pool of worker applications (consumers) retrieves orders from the queue, processes payments, updates inventory, and generates shipping labels. This decoupling ensures that order submission is fast and reliable, and the processing workload is distributed.

Use Case 2: Email Notification Service

  • Scenario: A web application sends email notifications for various user activities (e.g., sign-up, password reset).

  • Implementation: User actions trigger messages to be sent to a queue (e.g., Azure Queue Storage). An email service retrieves messages from the queue and sends out the emails. This ensures that email sending does not block the user’s primary action and provides resilience and scalability.


Publish/Subscribe (Pub/Sub) Systems

Pub/Sub systems enable broadcasting messages to multiple subscribers, allowing for scalable and flexible message distribution.

Use cases

Use Case 1: Real-Time News Feed

  • Scenario: A social media platform updates users' news feeds in real-time.

  • Implementation: User activities (e.g., posting, liking) generate events that are published to a pub/sub system (e.g., Google Cloud Pub/Sub). Subscribers (news feed services) receive these events and update the relevant users’ feeds instantly, ensuring that users see updates in real-time.

Use Case 2: IoT Data Aggregation

  • Scenario: An IoT solution collects data from various sensors.

  • Implementation: Sensors publish data to an MQTT broker (e.g., RabbitMQ with MQTT plugin). Multiple services subscribe to specific topics to process and analyze sensor data for various purposes like monitoring, alerting, and analytics.


Event Streaming Platforms

Event streaming platforms handle high-volume, real-time data streams for analytics and processing.

Use Cases

Use Case 1: Fraud Detection in Financial Transactions

  • Scenario: A financial institution monitors transactions for fraudulent activity.

  • Implementation: Transactions are streamed to a platform like Apache Kafka. A stream processing engine analyzes the data in real-time to detect patterns indicating fraud. Suspicious transactions trigger alerts or automated actions like account holds.

Use Case 2: Clickstream Analysis

  • Scenario: An e-commerce website analyzes user behavior for personalized recommendations.

  • Implementation: User interactions are streamed to Amazon MSK (Managed Streaming for Apache Kafka). Real-time analytics are performed to track user journeys and behavior, enabling personalized product recommendations and targeted advertising.


Event Routing and Processing

Event routing and processing services manage event-driven architectures by routing and processing events from various sources.

Use Cases

Use Case 1: Serverless Event-Driven Architecture

  • Scenario: An application integrates multiple microservices that need to respond to various events.

  • Implementation: Azure Event Grid routes events (e.g., file uploads to Azure Blob Storage) to Azure Functions that process these events (e.g., image processing, data validation). This architecture allows for efficient, scalable, and decoupled event handling.

Use Case 2: Real-Time Inventory Management

  • Scenario: A retail chain manages inventory levels in real-time across multiple stores.

  • Implementation: AWS EventBridge captures inventory events from different stores and routes them to Lambda functions that update the central inventory system. This ensures that the inventory data is always up-to-date and accurate.


Stream Processing

Stream processing services allow for real-time data analytics and transformation.

Use Cases

Use Case 1: Social Media Sentiment Analysis

  • Scenario: A company tracks social media mentions to gauge public sentiment.

  • Implementation: Social media feeds are ingested into Azure Event Hubs. Azure Stream Analytics processes these streams in real-time to analyze sentiment and generates insights, which are then visualized in Power BI dashboards.

Use Case 2: Predictive Maintenance for Manufacturing

  • Scenario: A manufacturing plant predicts equipment failures to perform maintenance proactively.

  • Implementation: Sensor data from machinery is streamed into AWS Kinesis Data Streams. A real-time processing application analyzes the data for signs of wear and tear, predicting failures before they occur and scheduling maintenance to prevent downtime.

Enterprise Messaging Systems

Enterprise messaging systems provide robust, scalable, and feature-rich messaging solutions for complex enterprise environments.

Use Cases

Use Case 1: Banking Transaction System

  • Scenario: A bank processes millions of transactions daily, ensuring consistency and reliability.

  • Implementation: IBM MQ is used to queue and process transactions, ensuring messages are delivered reliably and in the correct order. This system guarantees transaction integrity and supports various transaction types.

Use Case 2: Airline Reservation System

  • Scenario: An airline manages booking and reservation data.

  • Implementation: TIBCO EMS (Enterprise Message Service) handles communication between different parts of the booking system, ensuring real-time updates and consistent data across all systems involved in reservations, ticketing, and customer service.


Managed Messaging Services

Managed messaging services are provided by cloud vendors and offer ease of use, scalability, and integration with other cloud services.

Use Cases

Use Case 1: Microservices Communication

  • Scenario: A large-scale application with multiple microservices needs reliable communication.

  • Implementation: Amazon SQS and SNS are used to manage messaging between microservices. SQS ensures reliable task queuing while SNS handles event notifications and pub/sub messaging, providing a robust communication framework.

Use Case 2: E-commerce Order Fulfillment

  • Scenario: An e-commerce platform processes orders and updates inventory.

  • Implementation: Azure Service Bus is used to manage messages between the order processing system and inventory management. This setup ensures reliable message delivery, order tracking, and inventory updates, providing a seamless order fulfillment process.


References

PreviousBuilding BlocksNextCache

Last updated 9 months ago

Was this helpful?

: Fully managed queuing service supporting standard and FIFO queues.

: Simple message queuing for large numbers of messages.

: Task scheduling and execution service.

: Enterprise-grade messaging middleware.

: Open-source message broker supporting multiple messaging protocols.

: Open-source message broker with support for JMS and other protocols.

(Simple Notification Service): Fully managed pub/sub messaging service.

: Real-time messaging service for event ingestion and delivery.

: Supports pub/sub through topics and subscriptions.

: Distributed streaming platform suitable for high-throughput pub/sub.

: In-memory data structure store with pub/sub capabilities.

: High-throughput, low-latency platform for distributed streaming.

(Managed Streaming for Apache Kafka): Fully managed Kafka service.

: Big data streaming platform and event ingestion service.

: Managed Kafka service by Confluent.

: Managed Kafka service by IBM.

: Kubernetes-native Kafka platform.

: Fully managed event routing service for building event-driven applications.

: Event bus for routing events between AWS services and custom applications.

: Event-driven serverless compute service for lightweight processing.

: Serverless compute service triggered by events from other AWS services.

: Real-time data stream processing with SQL-based query language.

: Real-time data streaming service.

: Fully managed service for real-time stream and batch processing.

: Open-source stream processing framework.

: Distributed real-time computation system.

: Reliable messaging middleware for enterprise systems.

(Enterprise Message Service): Enterprise messaging platform supporting JMS.

(AQ): Message queuing service built into Oracle Database.

: Distributed messaging and streaming platform for high-performance use cases.

and : Managed queuing and pub/sub services.

and : Managed messaging and event streaming services.

and : Managed pub/sub and task scheduling services.

: Managed Apache Kafka service.

Amazon SQS (Simple Queue Service)
Azure Queue Storage
Google Cloud Tasks
IBM MQ
RabbitMQ
Apache ActiveMQ
Amazon SNS
Google Cloud Pub/Sub
Azure Service Bus
Kafka
Redis Pub/Sub
Apache Kafka
Amazon MSK
Azure Event Hubs
Confluent Cloud
IBM Event Streams
Red Hat AMQ Streams
Azure Event Grid
AWS EventBridge
Google Cloud Functions
AWS Lambda
Azure Stream Analytics
AWS Kinesis Data Streams
Google Cloud Dataflow
Apache Flink
Apache Storm
IBM MQ
TIBCO EMS
Oracle Advanced Queuing
Apache Pulsar
Amazon SQS
SNS
Azure Service Bus
Event Hubs
Google Cloud Pub/Sub
Tasks
IBM Cloud Message Hub
https://learn.microsoft.com/en-us/azure/architecture/guide/technology-choices/messaging
https://cloud.google.com/tasks/docs
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/welcome.html
https://azure.microsoft.com/en-in/products/storage/queues#Resources
https://www.ibm.com/products/mq
https://www.rabbitmq.com/docs
https://activemq.apache.org/
https://docs.aws.amazon.com/sns/
https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview
https://cloud.google.com/pubsub/docs/overview
https://www.ibm.com/blog/ibm-message-hub-is-now-ibm-event-streams/
https://docs.oracle.com/cd/B10500_01/appdev.920/a96587/qintro.htm
https://pulsar.apache.org/docs/3.3.x/
https://docs.tibco.com/pub/ems/10.3.0/doc/pdf/TIB_ems_10.3.0_user_guide.pdf?id=2
https://storm.apache.org/releases/2.6.2/index.html
https://nightlies.apache.org/flink/flink-docs-stable/
https://cloud.google.com/dataflow#stream-analytics
https://docs.aws.amazon.com/streams/latest/dev/introduction.html
https://learn.microsoft.com/en-us/azure/stream-analytics/stream-analytics-stream-analytics-query-patterns
https://kafka.apache.org/documentation/#gettingStarted
https://docs.aws.amazon.com/msk/latest/developerguide/getting-started.html?refid=0c835ec3-3fbf-4e72-802c-19a02d6e2337
https://learn.microsoft.com/en-us/azure/event-hubs/
https://www.ibm.com/products/event-streams
https://www.redhat.com/en/resources/amq-streams-datasheet
https://learn.microsoft.com/en-us/azure/event-grid/overview
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-what-is.html
https://cloud.google.com/functions#documentation
https://redis.io/docs/latest/develop/interact/pubsub/
https://aws.amazon.com/lambda/resources/
💎
🔹
Page cover image