プリフェッチ (QoS) は、コンシューマーが一度に保持できる未確認メッセージの数を制限し、ワーク分配を制御してOne つのコンシューマーが圧倒されるのを防ぎながら、他は遊んでいる状態を避けます。公平で効率的なメッセージ処理にとって重要です。
プリフェッチの役割
PREFETCH (QoS - prefetch count) → limits the number of UNACKNOWLEDGED messages a consumer
can have at once:
→ without it → RabbitMQ may dispatch many messages to one consumer (it grabs a batch)
→ with prefetch=N → a consumer gets at most N unacked messages at a time (must ack to get more)
→ controls how messages are distributed and how much a consumer buffers
なぜ重要なのか (公平な配信)
Without prefetch (or too high):
✗ one consumer might grab MANY messages (even slow-to-process ones) while others sit idle
→ unfair distribution, poor load balancing
With appropriate prefetch:
✓ FAIR DISPATCH → messages distributed more evenly (a busy consumer doesn't hoard messages)
✓ a slow consumer holds fewer; a fast one gets more (work flows to available consumers)
→ prefetch enables fair, efficient work distribution among consumers
