System Design, Infrastructure

Message Queue

A corgi smiling happily

A message queue is a durable component stored in memory that supports asynchronous communication. It served as a buffer and distributed asynchronous requests. The basic architecture is simple.

Decoupling makes the messages queue a preferred architecture for building scalable and reliable applications. With the message queue, the producer can post a message to the queue when the consumer is unavailable to process it. The consumer can read messages from the queue even when the producer is unavailable.

Consider the following use case: your application supports photo customization, including cropping, sharpening, blurring, etc. Those customization tasks take time to complete in the following figure. Web servers publish photo processing jobs to the message queue. Photo processing workers pick up jobs from the message queue and perform photo customization tasks asynchronously. A producer and consumer can be scaled independently. When the queue size becomes large, more workers are added to reduce the processing time. However, if the queue is empty most of the time, the member of workers can be reduced.

🍇

Do you have any questions, or simply wish to contact me privately? Don't hesitate to shoot me a DM on Twitter.

Have a wonderful day.
Abhishek 🙏

Subscribe to my newsletter

Get email from me about my ideas, full-stack development resources, tricks and tips as well as exclusive previews of upcoming articles.

No spam. Just the highest quality ideas you’ll find on the web.