Managing and Duplicating RabbitMQ Memory

I am currently evaluating RabbitMQ for queue management. I was wondering how RabbitMQ controls the queue element in memory.

in this example, the publisher’s subscriber is http://www.rabbitmq.com/tutorials/tutorial-three-python.html rabbitMQ Publisher subscriber

Does it create a queue for each subscriber (consumer)? for example, if I have two users, then I double the memory usage for storing the message?

I get the impression that if I join several workers in the queue, it will become a work queue in which each of the consumers received a different message.

Let's say that I am creating a chat server for this. Do I need to create a queue for each user? And each message in memory will be multiplied by the number of connected users? or there is only one message in memory, and each queue has a pointer to this message.

Also in the example post topic. http://www.rabbitmq.com/tutorials/tutorial-five-python.html

Topic message

let's say I have a 1 kb message. so is there 2kb memory usage for queue 2? Q1, Q2 and say that the message matches all the anchor keys.

If I added another queue to listen, let's say lazy.blue.* Like Q3. Will this create a new queue element in memory? and duplicate data?

+4
source share
3 answers

From: http://www.rabbitmq.com/blog/2011/01/20/rabbitmq-backing-stores-databases-and-disks/

If Rabbit must save memory and write to disk, only one message is saved.

“The queues themselves decide when and whether to write a message to disk. But one message can be sent to several queues, and it is obviously beneficial to make sure that each message is only written to disk once. However, there are two different pieces of information here: - first, the content of the message itself. This is the same in each queue to which the message was sent, and should only be written to disk once, regardless of the number of queues it goes to, note that subsequent entries from this have to do equalization of values: if the message identifier is known to the backup storage, then the message body will correspond to what is already on the disk. The message content is never changed by the broker. The second part of the information is the presence of the message in each queue: where in the queue lies, what are its neighbors and What is his status in the queue? This second part of the information is what allows RabbitMQ to start, restore messages and queues from disk and ensure that the messages in each queue are in the same order as when disconnected RabbitMQ.

Thus, the default backup storage RabbitMQ consists of a node-global global message store, which only deals with writing the contents of a message to disk; and a queue queue index, which uses a completely different format for writing to a message for each data queue on disk "

+3
source

In the first example, you have one publisher that sends messages to a specific exchange, and this exchange is tied to two queues.

As for creating a queue for each consumer (I assume what you mean when you say “subscriber”), it is entirely up to you. There are no consumer impressions in the first diagram, but you can configure the consumer (s) to listen to messages in one of these queues or both. Queues (not consumers) will affect your memory; exchanges in comparison are cheap in terms of memory cost.

For the second diagram, yes, creating the third Q3 queue would create a new queue in memory. I'm a little confused by your last question, you seem to be asking what happens if the exchange sends a message matching all the binding patterns? If this happens, the message will simply be sent to all three queues. The exchange of the type of topic (as the exchange is established in the example) simply sends messages to all queues whose binding key corresponds to the message routing key.

+1
source

I am not a hacker, but common sense says that each queue should have a pointer to one unique copy of the message.

0
source

Source: https://habr.com/ru/post/1441747/


All Articles