The lazy queue in RabbitMQ is a specially designed type of queue whose core feature is that messages are written directly to the disk for storage rather than being saved in memory first. This design enables lazy queues to significantly reduce memory consumption, making them particularly suitable for scenarios involving large volumes of backlogged messages. When messages arrive at a lazy queue, RabbitMQ immediately persists them to the disk. Only when consumers are ready to process the messages are they loaded into memory.
Lazy queues are suitable for the following scenarios:
A large number of messages need to be processed suddenly, such as when a log collection system may suddenly receive massive log messages during peak business hours.
Low-priority messages or messages that allow delays are processed, such as non-real-time report generation or offline analysis tasks.
The running environment has limited memory resources. An example is edge compute nodes or embedded devices.
Historical messages need to be saved for extended periods without consuming excessive memory. An example is the storage of certain compliance audit logs.
Note that since messages are written directly to the disk, lazy queues have slightly lower throughput performance than classic queues. They are typically suitable for business scenarios that do not require high real-time performance but need stable processing of large volumes of messages.
Constraints and Limitations
Currently, only Managed Edition clusters support configuring lazy queues. The Serverless Edition features distributed high-availability clusters and does not require configuring lazy queues.
Configuring Lazy Queue
When creating a queue, select whether to enable Lazy Mode in Other Advanced Options. For specific steps, see Creating a Queue.