0
0
RabbitmqDebug / FixBeginner · 3 min read

How to Fix Memory Alarm in RabbitMQ Quickly

To fix a memory alarm in RabbitMQ, increase the memory limit or clear large queues causing high memory use. You can adjust the limit with rabbitmqctl set_vm_memory_high_watermark or restart RabbitMQ after freeing memory.
🔍

Why This Happens

RabbitMQ raises a memory alarm when it detects that the memory usage on the server is too high. This alarm stops new messages from being accepted to prevent the server from crashing. It usually happens when queues hold too many messages or the memory limit is set too low.

bash
rabbitmqctl set_vm_memory_high_watermark 0.1
# This sets the memory limit to 10% of total RAM, which might be too low for your workload
Output
Memory alarm triggered: memory usage exceeded 10% of total RAM
🔧

The Fix

Increase the memory limit to a safer value like 40% of total RAM or clear large queues to reduce memory use. Use rabbitmqctl set_vm_memory_high_watermark 0.4 to raise the limit. Restart RabbitMQ if needed after freeing memory.

bash
rabbitmqctl set_vm_memory_high_watermark 0.4
rabbitmqctl stop_app
rabbitmqctl start_app
Output
Memory alarm cleared, RabbitMQ running normally
🛡️

Prevention

To avoid memory alarms in the future, monitor queue sizes and memory usage regularly. Set a reasonable memory watermark based on your server's RAM and workload. Use policies to limit queue length or message TTL to prevent queues from growing too large.

  • Use rabbitmqctl list_queues name messages to check queue sizes.
  • Set memory watermark to 40% or higher if your server has enough RAM.
  • Apply queue length limits with policies to auto-drop old messages.
⚠️

Related Errors

Other common RabbitMQ errors related to resource limits include:

  • File descriptor alarm: Happens when too many files/sockets are open. Fix by increasing OS limits.
  • Disk space alarm: Triggered when disk space is low. Fix by cleaning logs or increasing disk space.

Key Takeaways

Increase RabbitMQ memory watermark to prevent memory alarms.
Clear or limit large queues to reduce memory usage.
Monitor memory and queue sizes regularly.
Use policies to limit queue length and message TTL.
Restart RabbitMQ after fixing memory issues to clear alarms.