Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is RabbitMQ, ZeroMQ, Service Broker or something similar an appropriate solution for creating a high availability database webservice?

I have a CRUD webservice, and have been tasked with trying to figure out a way to ensure that we don't lose data when the database goes down. Everyone is aware that if the database goes down we won't be able to get "reads" but for a specific subset of the operations we want to make sure that we don't lose data.

I've been given the impression that this is something that is covered by services like 0MQ, RabbitMQ, or one of the Microsoft MQ services. Although after a few days of reading and research, I'm not even certain that the messages we're talking about in MQ services include database operations. I am however 100% certain that I can queue up as many hello worlds as I could ever hope for.

If I can use a message queue for adding a layer of protection to the database, I'd lean towards Rabbit (because it appears to persist through crashes) but since the target is a Microsoft SQL server databse, perhaps one of their solutions (such as SQL Service Broker, or MSMQ) is more appropriate.

The real fundamental question that I'm not yet sure of though is whether I'm even playing with the right deck of cards (so to speak).

With the desire for a high-availablity webservice, that continues to function if the database goes down, does it make sense to put a Rabbit MQ instance "between" the webservice and the database? Maybe the right link in the chain is to have RabbitMQ send messages to the webserver?

Or is there some other solution for achieving this? There are a number of lose ideas at the moment around finding a way to roll up weblogs in the event of database outage or something... but we're still in early enough stages that (at least I) have no idea what I'm going to do.

Is message queue the right solution?

like image 415
Alex C Avatar asked Aug 29 '12 15:08

Alex C


People also ask

What is RabbitMQ?

What is RabbitMQ? RabbitMQ gives your applications a common platform to send and receive messages, and your messages a safe place to live until received. What is ZeroMQ?

Why should you depend on RabbitMQ for Cloud Messaging?

You can depend on it when you need highly-reliable cloud messaging service between applications and services, even when one or more is offline; * RabbitMQ:** A messaging broker - an intermediary for messaging. RabbitMQ gives your applications a common platform to send and receive messages, and your messages a safe place to live until received.

What is RabbitMQ in Azure service bus?

RabbitMQ gives your applications a common platform to send and receive messages, and your messages a safe place to live until received. Azure Service Bus and RabbitMQ can be primarily classified as "Message Queue" tools. RabbitMQ is an open source tool with 6.07K GitHub stars and 1.85K GitHub forks.

Which is better ActiveMQ or RabbitMQ or ZEROMQ?

Which is better, ActiveMQ, RabbitMQ, or ZeroMQ? There are lot of differences between all of these. But this will also depend on the language stack you are using. Among the above RabbitMQ is the one which is most popular and has good client libraries support in popular languages.


1 Answers

Introducing message queuing in between a service and it's database operations is certainly one way of improving service availability. Writing to a local temporary queue in a store-and-forward scenario will always be more available than writing to a remote database server, simply by being a local operation.

Additionally by using queuing you gain greater control over the volume and nature of database traffic your database has to handle at peak. Database writes can be queued, routed, and even committed in a different order.

However, in order to do this you need to be aware that when a database write is performed it is processed off-line. Even under conditions where this happens almost instantaneously, you are losing a benefit that the synchronous nature of your current service gives you, which is that your service consumers can always know if the database write operation is successful or not.

I have written about this subject before here. The user posting the question had similar concerns to you. Whether you do this or not is a decision you have to make based on whether this is something your consumers care about or not.

As for the technology stacks you are thinking of this off-line model is implementable with any of them pretty much, with the possible exception of Service broker, which doesn't integrate well with code (see my answer here: https://stackoverflow.com/a/45690344/569662).

If you're using Windows and unlikely to need to migrate, I would go for MSMQ (which supports durable messaging via transactional queues) as it's lightweight and part of Windows.

like image 175
tom redfern Avatar answered Sep 29 '22 07:09

tom redfern