When the memory usage exceeds the configured threshold or the remaining disk space is lower than the configured threshold, rabbitmq will temporarily block the connection of the client and stop receiving messages from the client, so as to avoid the server running out, and the heartbeat detection mechanism between the client and the server will also fail.
As shown in the figure, if the
blockedIt shows that the threshold is reached and the high load operation is completed
2. Memory control of rabbitmq
Refer to the help document:www.rabbitmq.com/configure.html
In case of warning, it can be modified and adjusted through configuration
$ rabbitmqctl set_vm_memory_high_watermark <fraction> $ rabbitmqctl set_vmmemory_high_watermark absolute 4.8GB #Or $ rabbitmqctl set_vmmemory_high_watermark 0.6
Fraction / value is the memory threshold. The default is 0.4/2gb, which means that when the memory of rabbitmq exceeds 40%, it will generate a warning and block the connection of all producers. Modifying the threshold value with this command will be invalid after the broker restarts. The threshold value set by modifying the configuration file will not disappear with the restart, but the same as modifying the configuration file
Current profile location:
#Default # vm_memory_high_watermark.ralative = 0.4 #The relative value of ralative is used to set the fraction. It is recommended that the value should be between 0.4 and 0.7, and not more than 0.7 vm_memory_high_watermark.ralative = 0.6 #The absolute value of absolute is used, but KB, MB and GB correspond to the following commands vm_memory_high_watermark.absolute = 4.8G
Before a broker node and a memory blocking producer, it will try to page the messages in the queue to the disk to free the memory space. Persistent and non persistent messages will be written to the disk. The persistent message itself has a copy in the disk, so the persistent messages will be cleared from the memory during the process of transferring.
By default, when the threshold value of memory Avenue is 50%, page feed will be processed
That is to say, when the memory threshold is 0.4 by default, when the memory exceeds 0.2, page feed will be performed.
For example, there is 1000mb of memory. When the utilization rate of memory reaches the limit of 400MB, but because the configured page feed memory is 0.5, 200MB of memory will be transferred to disk before reaching the limit of 400MB. So as to achieve file running
vm_memory_high_watermark.ralative = 0.4 vm_ memory_ high_ watermark_ paging_ Ratio = 0.7 (set value less than 1)
Why is the setting value less than 1? Because if the threshold value of 1 is set, the memory has reached the limit, and the significance of page changing is not very great.
When the remaining disk space is lower than a certain threshold, rabbitmq will also block the producer, so as to avoid running out of disk space due to non persistent message paging By default: when the disk alert value is 50MB, an alert will be given, which means that when the disk space is less than 50MB, the producer will be blocked and the process of page swapping of memory messages to the disk will be stopped. This threshold can be reduced, but it can not completely eliminate the possibility of disk crash caused by disk exhaustion. For example, in the check gap between two disk spaces, the first check is 60MB, the second check may be 1MB, and a warning will appear.
Modify by the following command
$ rabbitmqctl set_disk_free_limit <disk_limit> $ rabbitmqctl set_disk_free_limit memory_limit <fraction> disk_ Limit: fixed unit: KB MB GB Fraction: is the relative threshold, the recommended range is between 1.0 and 2.0（ (relative to memory)
The configuration file is as follows
disk_free_limit.relative = 3.0 disk_free_limit.absolute = 50MB
This work adoptsCC agreementReprint must indicate the author and the link of this article