Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is Message queue content stored?

While using the POSIX Message queues I noticed there were some files being created on the File system with the name I was creating the queues. My questions :

Q1. Do message queues queue up the messages on the Hard Disk and not RAM ?

Q2. If so, shouldn't this be very slow in implementation as it involves HardDisk ?


Edit:

I read this in the book The Linux Programming Interface :

On Linux, POSIX message queues are implemented as i-nodes in a virtual file system, and message queue descriptors and open message queue descriptions are implemented as file descriptors and open file descriptions, respectively. However, these are implementation details that are not required by SUSv3 and don’t hold true on some other UNIX implementations.

Even if it is VFS, it is still stored on the HardDisk, right ?

With this information in mind, can someone comment on the second question now ? (and / or First one also if there is something more to add)

like image 308
Amit Tomar Avatar asked Feb 27 '13 15:02

Amit Tomar


People also ask

Where are message queues stored?

In a queuing system, messages are stored at intermediate nodes until the system is ready to forward them. At their final destination they are stored in an electronic mailbox until the addressee is ready to read them.

Is message queue in memory?

In a message queue, messages are stored in memory and are processed in the order that they are received.

Is a message queue a file?

Message queues are stored in the main memory and are available only while the system is running and not preserved across system reboots. A file is a sequence of bytes, and by default, the system does not enforce a structure on those bytes.

Is message queue a shared memory?

The message queue is a buffer that is used in non-shared memory environments, where tasks communicate by passing messages to each other rather than by accessing shared variables.


1 Answers

Below link may give some clarity on first question http://man7.org/linux/man-pages/man7/mq_overview.7.html

Regarding second question, of course the file based queue will be slower than memory based one. But this may not be as slow as some random file access operations since it is optimized and implemented specific for queuing.

like image 89
Noushad Avatar answered Nov 06 '22 07:11

Noushad