All About Message Queues

All About Message Queues

Message queues are one of the most important components in software architecture.

A message queue is basically a queuing service used in micro services?to help different components of the system communicate asynchronously by passing messages between them.

Queues are absolutely great in scenarios where your application needs something done but doesn’t need the result right now as it's not a blocking call(sync call) and your system can wait for the result while parallelly processing other tasks. So,?Instead of calling a service using an API and waiting for a response, you can push the message to a queue and let the same business logic happen later.

They are a great way to make different components of the system self contained and more independent i.e decouple them.

?There are 3 components of a of a message queue - Producers, Messages and Consumers.

Producers push the messages into the queues and Consumers/Worker processes?read those messages and take actions.

A message is any information that is passed between the producer and the consumer. It contains all the information needed for the worker components to take actions. The format of the message in the queue becomes your data contract and any service that knows how to read that message format can be used to process the message.

Eg, if we have to update the user address, The worker component needs to know details like: user_id, house_no, city, country

The message the producer creates and puts into a message queues will look something like this:

{

"user_id": 12345,

"house_no": 567,

"city": "Tokyo",

"country": "Japan"

}

?Queues are a great means to increase fault tolerance and scalability in the system. Even if the producer component fails, the consumer would still keep pulling messages from the queue and continue the tasks. Similarly if the consumer or worker stops working, the producer would still keep pushing messages into the queue. Hence it helps in decoupling of both these components as they are not dependent on each other thus making the system fault tolerant.

Now since the components are independent of one another they can be scaled independently too. If the worker processes are doing all the heavy-weight work then powerful machines can be used to run Worker service. Similarly more tasks can be added if the number of users increase. With this architecture it becomes possible to scale the different components independently.

Raj Bhattacharya

Tech | Big data| software dev | Data Science

2 年

Great read!

Demitri Swan

Sr. SWE @ Apple | Ex-Google, Ex-DigitalOcean | Backend, Infrastructure, Cloud

2 年

Typically the workers depicted here are refered to as consumers. Good topic.

要查看或添加评论,请登录

Pratima Upadhyay的更多文章

  • The Rise of Indian SaaS Startups : Comparing SaaS with IaaS and PaaS

    The Rise of Indian SaaS Startups : Comparing SaaS with IaaS and PaaS

    Did you know, despite the tight macroeconomic pressure and funding crunch, Indian SaaS startups have raised more than…

    2 条评论
  • Master the Art of System Design: Enroll in My Live Course and Strengthen Your Fundamentals

    Master the Art of System Design: Enroll in My Live Course and Strengthen Your Fundamentals

    Register for the course Are you ready to take your technical skills to the next level? Look no further than my live…

    1 条评论
  • Properties of Pub Sub Architecture

    Properties of Pub Sub Architecture

    Topics in a publish-subscribe system not only act as intermediaries between publishers and subscribers, but they also…

    5 条评论
  • What are coroutines and how are they different from threads?

    What are coroutines and how are they different from threads?

    Coroutines are a programming construct that can be thought of as a lightweight version of threads. While threads are…

    2 条评论
  • How are user passwords managed and validated in databases?

    How are user passwords managed and validated in databases?

    Did you know, back in 2005, Reddit developers confirmed that a hacker had stolen backup copies of their database that…

    3 条评论
  • Pub/Sub Messaging Model

    Pub/Sub Messaging Model

    Pub-Sub messaging is an asynchronous communication method used in microservice architecture. The Pub-Sub model consists…

    4 条评论
  • An introduction to Kubernetes

    An introduction to Kubernetes

    What is Kubernetes and why is it so popular? Kubernetes is an open source container orchestration tool developed by…

    2 条评论
  • An introduction to Containers

    An introduction to Containers

    Have you ever wondered what is the buzz around containers and why is everyone moving towards containerizing their…

    2 条评论
  • The birth and rise of NoSQL

    The birth and rise of NoSQL

    The acronym NoSQL was first used in 1998 by Carlo Strozzi while naming his lightweight, open-source “relational”…

    3 条评论
  • Replication and Sharding

    Replication and Sharding

    Replication refers to having several copies of the same dataset hosted on separate machines in order to maintain…

    12 条评论

社区洞察

其他会员也浏览了