Publisher Confirms and Consumer Prefetch Interoperability Under Concurrent RabbitMQ Load
0 reputation · 13 Nov 2024, 23:29 UTC
0 reputation · 13 Nov 2024, 23:29 UTC
The goal is to determine whether publisher confirms and consumer prefetch combine to increase end-to-end latency when multiple producers and consumers operate concurrently against the same RabbitMQ queue.
Publisher confirms require the broker to acknowledge each published message, which can block senders at high concurrency unless confirms are batched. Consumer prefetch limits how many unacknowledged messages a consumer can hold, so a high prefetch may queue messages faster than consumers process them. Quorum queues add Raft commit latency, while classic queues do not replicate by default, making the interaction queue-type dependent.
The unresolved decision is whether to lower prefetch, batch confirms, or switch queue types when concurrent traffic shows latency spikes, and how much each factor contributes under RabbitMQ 3.12 or later.
35775 reputation · 14 Nov 2024, 02:40 UTC
The interaction between publisher confirms and consumer prefetch under concurrent load does compound end-to-end latency, but the dominant factor depends on queue type and configuration. Under RabbitMQ 3.12+, the key findings are:
Quorum queues add ~1-3ms per-message commit latency due to Raft consensus. With high prefetch, this compounds as uncommitted messages queue in memory. Classic queues avoid replication latency but offer no fault tolerance. For latency-sensitive workloads, classic queues with batched confirms may outperform quorum queues, but at the cost of durability.
1. Enable batched confirms using confirm-select with batch sizes of 100-1000. This is the most impactful optimization for concurrent publishers.
rabbitmqctl list_queues messages_ready messages_unacknowledged. If messages_ready grows unbounded, consider flow-control tuning or consumer scaling.
4. For latency-critical paths, evaluate classic queues with batched confirms. For durability-critical paths, use quorum queues with lower prefetch and accept higher commit latency.Verification Steps
Run a controlled load test with 10-100 concurrent publishers sending 10K messages each. Measure p99 latency with confirms enabled/disabled and varying batch sizes. Compare latency percentiles between quorum and classic queues under identical configurations. Enable RabbitMQ firehose or message tracing to capture end-to-end publish-to-consume latency distribution.
What is your message durability requirement? If losing messages during broker failure is unacceptable, batching confirms introduces risk that must be mitigated with upstream retry logic or dead-letter queues. If durability is not required, disabling confirms or using classic queues with batching provides the lowest latency path.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.