AMQP Prefetch Optimizer

AMQP Prefetch Optimizer

animation
amqp
protocols
messaging
Try Change Prefetch count: from 1 to 100.
Observe Watch Throughput, Avg Latency, Batch Time, and Efficiency as prefetch increases from 1.
Explain Explain why increasing prefetch from 1 changes network overhead per message.

Technical boundaries. Batch time is prefetch count times message processing time plus one network RTT per batch. Throughput and latency use this batch calculation.

AMQP Prefetch Optimizer

Explore the tradeoff between throughput (higher prefetch) and latency (lower prefetch) for optimal consumer performance.

Key Insights:

First: Prefetch count controls the tradeoff between throughput and latency. Low prefetch (1-10) minimizes per-message latency but adds network overhead. High prefetch (100+) maximizes throughput but delays fair work distribution across consumers.

Next: Backlog payload scales with message count and size. A 10-second backlog at 500 msg/sec is 5,000 messages; at 1 kB of payload each, that is 5 MB of payload before queue metadata, disk/index overhead, and replication. It is not a 5 MB RAM requirement.

Then: Consumer service capacity is approximately consumers × (1000 / processing_time_ms) messages/sec for sequential, fully busy workers with no other bottleneck. At 10 ms per message, one worker could process about 100 msg/sec. Little’s Law separately relates average work in progress to arrival rate and time in system.

Back to the chapter