Skip to main content
InterviewHubPRO
Section Overview
Q8

Question 8 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

16%
RabbitMQ & AMQP (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

What is Consumer Prefetch (`basic.qos` / `prefetch_count`) and why is it critical?

junior LevelCode ExampleRabbitMQHTTP & REST APIs

In Simple Words: By default, RabbitMQ pushes messages to consumers as fast as the network allows (Round-Robin distribution).

  • If Consumer A receives 10 heavy, 10-second processing tasks, and Consumer B receives 10 instant 5ms tasks:
    • Consumer B finishes instantly and sits idle.
    • Consumer A's RAM fills up with queued messages and crashes!
  • prefetch_count (Quality of Service - QoS): Tells RabbitMQ: "Do not send more than $N$ unacknowledged messages to this consumer at one time."
    javascript
    // Set prefetch to 1: Fair dispatch
    channel.prefetch(1);
    
    RabbitMQ delivers a message to a worker only when that worker has acknowledged its previous message, distributing workloads evenly based on actual processing capacity.