Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Message Queues Vs DB Table Queue via CRON

We have a large project coming up soon with quite a lot of media processing (Images, Video) as well email output etc, the sort of stuff normally we'd put into a table called "email_queue" and we use a cron to run a script process the queue in the table.

I have been reading a lot on Message Queue systems like beanstalkd, and have even set it up. It was easy and nice to use, the problem is that I am unsure whether I am missing something.

Could someone detail the benefits of using a queue system rather than a table and a CRON? Since I really can't see to see what they are.

Thanks

like image 254
Bowen Avatar asked Dec 03 '09 15:12

Bowen


1 Answers

Differences:

  1. Once a message is put on the queue it can be immediately delivered. So if your cron normally ran every 5 minutes, you could process faster with the queuing.

  2. If your queueing system supports transactions, then it will automatically re-deliver a message if the processing fails.

  3. It can be harder to query what is in your queue. A database table has a nice way to search (sql).

  4. If you have multiple servers/processes/threads handling messages, the queue system will make sure a message is only delivered to one of them. With a DB table you need to handle this via application code (locking, flags, etc ...)

like image 124
Dave Avatar answered Oct 11 '22 16:10

Dave