Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Message queue like RabbitMQ for high volume writes to SQL database?

The scenario is needing to write high volume data, like tracking clicks or mouse movements, from a web application to a SQL database. The data doesn't need to be written right away because the analysis on the data happens on some recurring basis, like daily or weekly.

I want some feedback on a solution that comes to mind:

The click and mouse data is published to a message queue. This stores the queue items in memory so it should be fast and faster than SQL. Then on some other server a job plugs away on retrieving the next queue item and writing the data to SQL.

Does anyone know of implementations like this? What pitfalls am I failing to see? If this solution is not a good one are there other alternatives?

Regards

like image 301
Michael Avatar asked Nov 08 '22 16:11

Michael


1 Answers

RabbitMQ is meant for real time message exchange and not for temporary buffering data. If you are able to consume all data as soon as it arrives in your queues, then this solution will work for you. Otherwise RabbitMQ will grow in memory and eventually die. Then you will have to configure it to throw some data away (there are a lot of options to choose rules for this).

You could possibly store data in Redis cache, you can do it as fast as you publish your events to RabbitMQ. Then you can listen to the new changes in Redis from remote server and fill up whatever database storage you use, or even use it as your data storage.

like image 88
antken Avatar answered Nov 15 '22 09:11

antken