>_ IzzyLab

Hands-on task

This task is step 14 of the course “Redis in production”

A consumer group for the orders stream

medium~12 min

Redis has a stream orders with orders nobody has processed yet. Hook billing up to it:

  1. create a consumer group billing so that it receives all entries of the stream — from the very beginning, not only new ones;
  2. read the entries from the group as consumer worker-1;
  3. "process" them and acknowledge every entry you received, so the group has no pending messages left.

Don't change the stream itself: don't add or delete anything.

What you'll practise:
  • redis
  • streams
  • XGROUP
  • XREADGROUP
  • XACK
  • XPENDING

Topic breakdown

Redis Streams is a log of entries with IDs of the form <ms>-<seq>. A consumer group distributes entries among several workers: each entry goes to exactly one consumer of the group and lands in its Pending Entries List (PEL). It stays there until the worker acknowledges it with XACK — that is how Redis provides at-least-once delivery: if a worker crashes without acknowledging, the message isn't lost and can be handed to another one. A common mistake is to create the group with $: then the group never sees the entries already in the stream. A growing PEL in production is a sign that workers are crashing or forgetting to acknowledge messages.

What's checked

  1. billing group created
  2. orders stream unchanged
  3. the group received all stream entries from the start
  4. consumer worker-1 received the entries
  5. all received entries acknowledged

What it looks like