💻
System Design
  • System Design
  • System Design Overview
  • Basic Concepts
    • Memory Levels
    • Functional vs Non-Functional Requirements
  • Key Concepts and Definations
    • Scalability
    • Performance
    • Availability
    • Reliability
    • Consistency
    • Stateless vs Stateful Servers
    • CAP Theorem
    • Data Storage and Retrieval
    • Consistent Hashing
    • Rate Limit
    • Networking and Communication
    • Security and Privacy
  • Building Blocks
    • REST APIs
      • HTTP Request
    • Authentication and Authorisation
    • Caching
      • Caching with Redis + Python
      • LRU Caching Implementation
      • Caching: Case Study
    • Database
      • DBMS
      • SQL
      • NoSQL
      • Properties
      • Database
        • Elasticsearch
        • Neo4j
        • Redis
        • OrientDB
      • Use Cases
    • Message Queue
      • Kafka
      • Pulsar
      • Celery
      • Rabbimq
      • Redis
    • Deployment
      • Docker
        • Distroless
      • Kubernetes
      • CI - CD Pipeline
    • CDN
    • Nginx
      • Reverse Proxy
      • Load Balancer
      • Caching
    • Web Scrapper and Automation
    • Parallel Processing
    • Scheduling
      • Airflow
      • Azure Logic App
    • Networking Fundamentals
    • Cloud Services
      • AWS
        • Dynamic Website on AWS
      • Google Cloud
        • Dynamic Website on GCP
      • Azure
  • Miscellaneous
  • Git
    • Interesting Repos
      • Quantitative Finance
  • Visualization
    • Power BI
    • Kibana
    • Redash
  • rocksdb and Python
  • Python Framework
    • Python Concepts
      • miscellaneous Concepts
      • OOP
      • Built-in Class Attributes
      • Built-in Functions
      • Python Clean Code
      • Async io
      • Concurrency vs Parallelism
      • Client-Server Model
    • Flask
    • FastAPI
    • Tornado
    • Django
  • Java Script
    • Node js
    • Express js
  • Operating System
  • Big Data
    • Spark
      • Pyspark Working
    • EDW
      • EDW Concepts
    • GraphQL
    • Map Reduce
  • Search
  • UI UX
    • Figma
  • Logging in Python
  • Communication in Python
  • Hashing
  • Sample Application Structure
  • Data Transfer over Network
    • jwt Authentication
  • Rough
    • Authentication and Authorization
    • Pyspark Kubernetes Operator
    • Pulsar vs Kafka
    • Storage vs Compute Server
    • Bigdata Storage Server
    • Bigdata Storage + Compute Servers
    • Stream Data Storage
    • Columnary vs Row based
    • Big data Processing
    • Stream data Processing
    • Metadata and usage
    • Data Cataloging and Usage
    • Iceberg vs Hive
    • Page 1
  • SQL - A Complete Guide
    • SQL Queries
  • Data Engineer Interview
  • Elasticsearch
  • Lambda Architecture
  • Technology Stack
  • Machine Learning
    • Learning rate warm-up
  • System Designs
    • Thinking Mental Model
    • Design Fundamental Systems
      • Design Rate Limiter
      • Design Key-Value Store
      • Design a Web Crawler
      • Design Logging and Monitoring System
    • Design Spotify
    • Design ChatGPT
    • Design Tinder
    • Design Twitter
    • Design Hotel Booking System
    • Design Calender Management System
    • Design Reddit
    • Design Whatsapp
    • Design Youtube
    • Design Instagram
    • To Read
Powered by GitBook
On this page
  • What is it?
  • Why do we need it?
  • Types?
  • References for Further Reading

Was this helpful?

  1. Building Blocks

Message Queue

Basics, its types and use cases

PreviousUse CasesNextKafka

Last updated 3 years ago

Was this helpful?

What is it?

A message queue is an asynchronous service-to-service communication used in serverless and microservices architectures.

Putting the same thing in simple words, it is a process that puts a message onto a message queue and does not require an immediate response to continuing processing

  • Message queuing allows applications to communicate by sending messages to each other

  • The message queue provides temporary message storage, the purpose of it can be:

    • queue the tasks when the processor is busy or not connected

    • queue the tasks so that they can be processed in parallel (and/or distributed) - (example celery)

    • on-the-fly and real-time processing of data as it arrives (example Kafka as message queue)

Why do we need it?

Instead of building one large application, it is beneficial to decouple different parts of the application and communicate between them asynchronously using message queues

is very much in use now, few benefits of decomposing an application into different smaller services are:

  • Modularity: This makes the application easier to understand, develop, test, and become more resilient to architecture erosion

  • Scalability: Since microservices are implemented and deployed independently of each other, i.e. they run within independent processes, they can be monitored and scaled independently.

  • Integration of heterogeneous and legacy systems: The process for Software modernization of legacy applications is done using an incremental approach through microservice architecture

  • Distributed development: it parallelizes development by enabling small autonomous teams to develop, deploy and scale their respective services independently. Microservice-based architectures facilitate continuous integration, continuous delivery and deployment

Types?

Different types of message queues are in place for different purposes. I have encountered two types of message queues so far, Kafka is one type and Celery (using Redis, RabbitMQ, or AWS SQS) is another type

We can classify based on three properties:

  • Message replay is allowed

  • We can prioritize a particular task

  • Routing is possible; direct or regular expression-based routing allows messages to reach specific queues without additional code

When to use which service:

  • Kafka is used more for streaming that is "on-the-fly and real-time processing of data as it arrives", message replay is possible in Kafka that is message is not removed once it’s consumed. But, Kafka lack the ability to prioritize tasks or routing the incoming messages

  • Celery with RabbitMQ, Redis, or AWS SQS does not have the option to replay the messages, once the message is acked, it’s removed from the queue. However, it has ability to prioritize the message queues or route the incoming message

Therefore, two message queues have different use cases, and in many cases, two queues compliment each other to add extra capabilities to the system when used efficiently

References for Further Reading

Microservice architecture
What is message queuing? - CloudAMQP
Message queue explained
Logo
When to use RabbitMQ or Apache Kafka - CloudAMQP
Difference two message queues explained in previous section
Logo