Advertisement
Intermediate Redis, Streams

What is a consumer group in Redis Streams, and how does it enable multiple workers to process the same stream cooperatively?

Short answer

A consumer group lets multiple different consumers share the workload of processing a single stream, with Redis ensuring each message is only delivered to one consumer within that specific group, while different consumer groups can independently receive and process every message…

Save Redis mock interview
Advertisement
AModel answer
A consumer group lets multiple different consumers share the workload of processing a single stream, with Redis ensuring each message is only delivered to one consumer within that specific group, while different consumer groups can independently receive and process every message in the stream separately from each other.
Example

XGROUP CREATE orders processing_group '$' XREADGROUP GROUP processing_group worker1 COUNT 1 STREAMS orders '>'

Real-world example
An order processing system runs several worker instances all belonging to the same consumer group, with Redis automatically distributing each new order event to only one of the available workers, effectively load balancing the processing work.
Likely follow-ups
  • What happens if a worker in a consumer group crashes while processing a message?
  • Can you have multiple independent consumer groups reading the exact same stream?
Related topics