扩展 RabbitMQ 涉及扩展消费者(并行处理)、集群(多个节点)以及管理队列和负载。RabbitMQ 与 Kafka 的扩展方式不同,理解其扩展方法和限制对高负载部署很重要。
扩展消费者(主要杠杆)
✓ ADD CONSUMERS → multiple consumers on a queue process messages in PARALLEL (competing
consumers) → scale processing throughput → the primary way to scale consumption
✓ tune PREFETCH for fair, efficient distribution
✓ make processing efficient (fast consumers handle more)
→ horizontal consumer scaling handles more message processing
扩展代理(集群)
✓ CLUSTER → add nodes → distribute connections, channels, and queues across nodes → more
capacity (connections, throughput)
✓ Distribute QUEUES across nodes (a queue lives on one node by default → spread queues
to spread load)
✓ QUORUM QUEUES → replicated (HA) but with replication overhead
⚠️ a single QUEUE has throughput limits (it's processed in order on its node) → many
queues / sharding for very high throughput
