We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Prefetch

When you run a consumer, you may have assumed this process for message consumption:

  1. Fetch a message from the queue (across the network, which can be slow)
  2. Process the message
  3. Acknowledge the message
  4. Repeat

But that would slow everything down to a crawl due to the full network round trip for every message. Instead, RabbitMQ allows you to prefetch messages. When you prefetch messages, RabbitMQ will send you a batch of messages at once, the client library will store them in memory, and you can process them one by one. Much faster. The diagram shows 3 consumers each prefetching batches of 2.

Without a limit, one client can prefetch all 10,000 messages from the server, and other clients can't get any messages until it has processed them. That's why we set prefetch(1) earlier, but a prefetch of 1 pays a full network round trip for every message.

Assignment

This will ensure that each client only prefetches 10 messages at a time. This will allow other clients to get messages while one client is processing.

Run and submit the CLI tests with an empty game_logs queue.