Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Queues against Tables in messaging systems [closed]

I've been experiencing the good and the bad sides of messaging systems in real production environments, and I must admit that a well organized table or schema of tables simply beats every time any other form of messaging queue, because:

  1. Data are permanently stored on a table. I've seen so many java (jms) applications that lose or vanish messages on their way for uncaught exceptions or other bugs.
  2. Queues tend to fill up. Db storage is virtually infinite, instead.
  3. Tables are easily accessible, while you have to use esotic instruments to read from a queue.

What's your opinion on each approach?

like image 750
friol Avatar asked Nov 01 '08 17:11

friol


People also ask

How do I close message queue?

You can remove a message queue using the ipcrm command (see the ipcrm(1) reference page), or by calling msgctl() and passing the IPC_RMID command code. In many cases, a message queue is meant for use within the scope of one program only, and you do not want the queue to persist after the termination of that program.

What is messaging queue system?

Message Queues A message queue is a form of asynchronous service-to-service communication used in serverless and microservices architectures. Messages are stored on the queue until they are processed and deleted. Each message is processed only once, by a single consumer.

What are the different types of message queue?

The system has different types of message queues: workstation message queue, user profile message queue, job message queue, system operator message queue, and history log message queue.


2 Answers

The phrase beats every time totally depends on what your requirements were to begin with. Certainly its not going to beat every time for everyone.

If you are building a single system which is already using a database, you don't have very high performance throughput requirements and you don't have to communicate with any other teams or systems then you're probably right.

For simple, low thoughput, mostly single threaded stuff, database are a totally fine alternative to message queues.

Where a message queue shines is when

  • you want a high performance, highly concurrent and scalable load balancer so you can process tens of thousands of messages per second concurrently across many servers/processes (using a database table you'd be lucky to process a few hundred a second and processing with multiple threads is pretty hard as one process will tend to lock the message queue table)
  • you need to communicate between different systems using different databases (so don't have to hand out write access to your systems database to other folks in different teams etc)

For simple systems with a single database, team and fairly modest performance requirements - sure use a database. Use the right tool for the job etc.

However where message queues shine is in large organisations where there are lots of systems that need to communicate with each other (and so you don't want a business database to be a central point of failure or place of version hell) or when you have high performance requirements.

In terms of performance a message queue will always beat a database table - as message queues are specifically designed for the job and don't rely on pessimistic table locks (which are required for a database implementation of a queue - to do the load balancing) and good message queues will perform eager loading of messages to queues to avoid the network overhead of a database.

Similarly - you'd never use a database to do load balancing of HTTP requests across your web servers - as it'd be too slow - if you have high performance requirements for your load balancer you'd not use a database either.

like image 109
James Strachan Avatar answered Oct 14 '22 21:10

James Strachan


I've used tables first, then refactor to a full-fledged msg queue when (and if) there's reason - which is trivial if your design is reasonable.

The biggest benefits are a.) it's easier, (b. it's a better audit trail because you have the other tables to join to, c.) if you know the database tools really well, they are easier to use than the Message Queue tools, d.) it's generally a bit easier to set up a test/dev environment in a context that already exists for your app (if same familiarity applies).

Oh, and e.) for perhaps you and others, it's not another product to learn, install, configure, administer, and support.

IMPE, it's just as reliable, disconnectable, and you can convert if it needs more scalable.

like image 41
dkretz Avatar answered Oct 14 '22 22:10

dkretz