Adjust Linux Message Queue Size: Guide
To configure the message queue size in a Linux system, you can use the following command:
- Check the current size of the message queue.
- View the maximum byte size of messages in the message queue by checking the “kernel.msgmax” parameter.
View the maximum capacity of the message queue in bytes by checking the “kernel.msgmnb” parameter. - Adjusting the size of the message queue temporarily.
- Update the maximum message size and maximum capacity of the message queue by running the following commands:
sudo sysctl -w kernel.msgmax=[new message max size]
sudo sysctl -w kernel.msgmnb=[new message queue max capacity] - For example, to set the maximum capacity of the message queue to 2MB, you can execute the following command:
- Set the kernel message queue size to 2097152 bytes using the sudo sysctl command.
- This will temporarily modify the message queue size at runtime, but it will not be effective after system reboot.
- Permanently modify the message queue size by opening the /etc/sysctl.conf file and adding the following line to set the maximum capacity of the message queue and the maximum size of messages.
- kernel.msgmax = [new maximum message size]
kernel.msgmnb = [new maximum message queue size] - After saving the file, run the following command to make the configuration take effect:
- Please reload the sysctl settings.
- In this way, the message queue size will remain unchanged even after the system restarts.