T
T
topuserman2019-12-05 15:52:32
RabbitMQ
topuserman, 2019-12-05 15:52:32

How correct is it to create a large number of queues in RabbitmQ?

I often stumble upon cases where rabbitmq is used in applications or on websites as a system for delivering various notifications to the user,
while a queue is created for each user, and the user ID is used as the routing key.
Is this good practice? Isn't it scary to create a queue for each user? And is there anything to be taken into account? For example, should the queue be automatically opened if the user is offline or inactive?
What if there are a little more than a million users? million queues - will it somehow seriously affect performance if you do not take into account the amount of data in these queues?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Shumov, 2019-12-05
@inoise

- you can use topics
- you can use headers
- you can use json parameters in the message body

S
Sergey, 2019-12-05
@yarkin

It all depends on the task and terminology. For example, a "user" can be either some kind of system object that does not have a direct connection to RabbitMQ and is separated by a layer of other software, or be directly connected to it. In the first case, at the RabbitMQ level, you will need to be able to distinguish between types of middleware (for example, sending messages by mail, by cart, etc.), perhaps their groups (for example, sharding by region), and know the specific RabbitMQ user ID right here is not needed and can be part of the body of the message. In the second case, at the RabbitMQ level, it will already be necessary to distinguish between specific users and the ID should already be part of the metadata visible to RabbitMQ.
Further, if we move from the term "user" to the term "client" (for example), then in the first case the number of clients will be equal to the number of middleware instances (for example, 1000), and in the second case - the number of end users (for example, 1 million) . And here we can say that for each client (or a group of equivalent workers) you need to create a queue. In the first case, there will be a thousand, and in the second, a million.
And yes, RabbitMQ queues are not the easiest, in my experience (on version 3.6-3.7) 10 thousand queues took up about 800 MB of memory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question