How does RabbitMQ actually save the message physically?

I want to know how RabbitMQ saves messages physically in RAM and disk?

I know that RabbitMQ is trying to store messages in memory (But I do not know how messages are placed in Ram). But messages can be spilled to disk when messages are in constant mode or when the broker has memory pressure. (But I do not know how messages are stored on disk.)

I would like to know about this insides. Unfortunately, the official documentation on the home page does not reveal the internal details.

What document should I read for this?

+23
rabbitmq
source share
1 answer

RabbitMQ uses its own database for storing messages, the database is usually located here:

/var/lib/rabbitmq/mnesia/ rabbit@hostname /queues 

Starting from version 3.5.5, RabbitMQ introduced a new New Credit Flow https://www.rabbitmq.com/blog/2015/10/06/new-credit-flow-settings-on-rabbitmq-3-5-5/

Let's see how RabbitMQ queues store messages. When a message enters the queue, the queue must determine whether the message should be saved or not. If the message is to be saved, then RabbitMQ will do it right away [3]. Now, even if the message was saved on disk, this does not mean that the message was deleted from RAM, because RabbitMQ stores the message cache in RAM for quick access when delivering messages to consumers. Whenever we talk about pumping messages to disk, we talk about what RabbitMQ does when it has to send messages from this cache to the file system.

This blog post is quite detailed.

I also suggest reading about the lazy lineup: https://www.rabbitmq.com/lazy-queues.html and https://www.rabbitmq.com/blog/2015/12/28/whats-new-in-rabbitmq - 3-6-0 /

Lazy Queues This new type of queue works by sending every message it delivers directly to the file system and loading messages into RAM only when consumers arrive in the queue. To optimize disk reads, messages are downloaded in batches.

+15
source share

All Articles