Top 10 uses for a message queue
|
Geese love queues. (Image by D. hilgart) |
We 've been working with, building, and evangelising message queues for the last year, and it's no secret that we think they're awesome. we believe message queues are a vital component to any architecture or application, and here are ten reasons why:
- DecouplingIt's extremely difficult to predict, at the start of a project, what the future needs of the project will be. by introducing a layer in between processes, message queues create an implicit, data-based interface that both processes implement. this allows you to extend and modify these processes independently, by simply ensuring they adhere to the same interface requirements.
- RedundancySometimes processes fail when processing data. unless that data is persisted, it's lost forever. queues mitigate this by persisting data until it has been fully processed. the put-get-delete paradigm, which publish message queues use, requires a process to explicitly indicate that it has finished processing a message before the message is removed from the queue, ensuring your data is kept safe until you're done with it.
- ScalabilityBecause message queues decouple your processes, it's easy to scale up the rate with which messages are added to the queue or processed; simply add another process. no code needs to be changed, no comprehenations need to be tweaked. scaling is as simple as adding more power.
- Elasticity & spikabilityWhen your application hits the front page of Hacker News, you're going to see unusual levels of traffic. your application needs to be able to keep functioning with this increased load, but the traffic is anomaly, not the standard; it's wasteful to have enough resources on standby to handle these spikes. message queues will allow beleaguered components to struggle through the increased load, instead of getting overloaded with requests and failing completely. check out our spikability blog post for more information about this.
- ResiliencyWhen part of your architecture fails, it doesn't need to take the entire system down with it. message Queues decouple processes, so if a process that is processing messages from the queue fails, messages can still be added to the queue to be processed when the system recovers. this ability to accept requests that will be retried or processed at a later date is often the difference between an inconvenienced customer and a frustrated customer.
- Delivery Guarantees
The redundancy provided by message queues guarantees that a message will be processed eventually, so long as a process is reading the queue. on top of that, ironmq provides an only-delivered-once guarantee. no matter how many processes are pulling data from the queue, each message will only be processed a single time. this is made possible because retrieving a message "reserves" that message, temporarily removing it from the queue. unless the client specifically states that it's finished with that message, the message will be placed back on the queue to be processed after a retriable amount of time.
- Ordering guarantees
In a lot of situations, the order with which data is processed is important. message Queues are inherently ordered, and capable of providing guarantees that data will be processed in a specific order. ironmq guarantees that messages will be processed using FIFO (first in, first out ), so the order in which messages are placed on a queue is the order in which they'll be retrieved from it.
- BufferingIn any non-trivial system, there are going to be components that require different processing times. for example, it takes less time to upload an image than it does to apply a filter to it. message Queues help these tasks operate at peak efficiency by offering a buffer layer -- the process writing to the queue can write as fast as it's able, instead of being constrained by the readiness of the Process reading from the queue. this buffer helps control and optimise the speed with which data flows through your system.
- Understanding data flow
In a distributed system, getting an overall sense of how long user actions take to complete and why is a huge problem. message queues, through the rate with which they are processed, help to easily identify under-inform Ming processes or areas where the data flow is not optimal.
- Asynchronous Communication
A lot of times, you don't have want to or need to process a message immediately. message Queues enable asynchronous processing, which allows you to put a message on the queue without processing it immediately. queue up as your messages as you like, then process them at your leisure.
We believe these ten reasons make queues the best form of communication between processes or applications. we 've spent a year building and learning from ironmq, and our MERs are doing amazing things with message queues. queues are the key to the powerful, distributed applications that can leverage all the power that the cloud has to offer.
If you 'd like to get started with an efficient, reliable, and hosted message queue today, check out ironmq.If you 'd like to connect with our engineers about how queues cocould fit into your application, they're always available at get. Iron. IO/chat.
Original article address