RabbitMQ & AMQP (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
Priority Queues (`x-max-priority`): How binary heap indexing works and why priority levels should be kept low.
senior LevelMost AskedMemory ManagementSystem DesignDatabases & SQL
In Simple Words: Priority queues allow urgent messages (e.g., password reset OTPs) to jump ahead of background bulk tasks (e.g., monthly newsletter emails):
- Declared with
"x-max-priority": 10. - Erlang Heap Overhead: Each priority level internally creates a separate sub-queue/binary heap within the Erlang process.
- Best Practice: Never set
x-max-priority > 10(preferably 3 to 5). Setting priority to 255 consumes massive memory and severely degrades message ingestion rates.