Redis Streams design guide: choosing consumer groups, recovery, and trimming
Redis Streams is a Redis data type that stores time-ordered, uniquely identified entries like an append-only log and supports both ordinary reads and consumer groups. Use independent reads or separate groups when every subscriber needs each entry; use one group when workers should share work. For group consumption, acknowledge successful processing with XACK, and plan pending-entry recovery and stream trimming separately.
Redis Streams is a Redis data type that stores time-ordered, uniquely identified entries like an append-only log and supports both ordinary reads and consumer groups. Use independent reads or separate groups when every subscriber needs each entry; use one group when workers should share work. For group consumption, acknowledge successful processing with XACK, and plan pending-entry recovery and stream trimming separately.
Choose a read pattern
XADD appends an entry and can generate its unique ID. XREAD reads entries after a supplied ID, so independent applications can each read the same stream. XREADGROUP distributes new entries among consumers in a group. Consumers in one group share entries, while different groups can each process the same entries.
| Need | Read design | Check operationally |
|---|---|---|
| Every app independently receives every event | Give each app a consumer group or an independent cursor | Manage each reader's position and retention window |
| Workers divide a job | One group with a unique consumer name per worker | Plan how to recover and reassign pending entries after failure |
| Low-reliability notification data | Consider NOACK only when appropriate | Use only if loss is acceptable without pending tracking or retry |
| Bound old data | Set XTRIM MAXLEN or MINID | Trimmed entries cannot be read again from the stream |
Pending entries and acknowledgments
By default, XREADGROUP records a delivered entry in that group's Pending Entries List (PEL). XACK removes a successfully processed entry from the group's PEL. It does not delete the source entry from the stream. The entry may remain available to other groups or through XRANGE, so retention and deletion need their own policy.
Acknowledging before processing can mark unfinished work complete if a failure occurs. Acknowledging after processing can lead to duplicate effects if the process fails between the effect and XACK. Make external database updates or payments idempotent, or reconcile them with business state.
Pending entries are not completed automatically when a consumer stops. Use XPENDING to inspect entries and idle time; according to your recovery policy, another consumer can take ownership with XAUTOCLAIM or XCLAIM. Claiming does not eliminate the possibility of duplicate processing. Set the idle threshold above normal maximum processing delay and make retries safe.
Retention and trimming
Streams can grow without bound. XTRIM or trimming options on XADD can limit length with MAXLEN or entry IDs with MINID. Approximate trimming with ~ can be more efficient while leaving a few entries above the threshold. Trimming removes old source entries, so choose limits based on replay needs, consumer lag, and capacity.
Since Redis 8.2, KEEPREF, DELREF, and ACKED options control how trimming affects consumer-group PEL references. KEEPREF (the default) may retain PEL references after removing stream entries; DELREF removes those references; ACKED trims only entries acknowledged by every group. Check support and behavior in your deployed version. A retained PEL reference does not mean the entry's stream data can still be recovered.
Checks before launch
**Choose the delivery topology.** Decide whether every independent subscriber needs all events or workers should split entries, then define group boundaries.
**Define completion.** Specify which durable or business effect must finish before XACK, and record the crash windows and duplicate outcomes.
**Operate pending recovery.** Monitor pending counts and idle times; define claim, retry, and quarantine conditions for consumer failures.
**Make reprocessing safe.** Consider idempotency keys, deduplication records, or transactional outbox/inbox patterns for external effects.
**Calculate the trim limit.** Retain enough data for consumer outages and reprocessing, and state when trimming makes source entries unavailable.
**Exercise failure paths.** Stop a consumer just after reading, after the business effect, and around XACK; inspect pending state, redelivery, and duplicates. These are recommended checks, not tests claimed to have been run.
Redis Streams is a Redis data type; by itself it does not provide exactly-once business effects across external systems. Verify durability, replication, and recovery guarantees for your Redis deployment, configuration, and command version.
Sources and scope
Redis, [Streams data type](https://redis.io/docs/latest/develop/data-types/streams/)
Redis, [XREADGROUP](https://redis.io/docs/latest/commands/xreadgroup/)
Redis, [XACK](https://redis.io/docs/latest/commands/xack/)
Redis, [XTRIM](https://redis.io/docs/latest/commands/xtrim/)
Based on Redis official latest documentation read on 2026-11-19. Consumer groups are available since Redis 5.0, MINID since 6.2, and group-reference trimming options since 8.2. Commands and options vary by deployment and version; verify compatibility against your server.