Redis Streams Consumer Groups: Reliable Ordered Messaging
Learn how Redis Streams with consumer groups provide ordered, at‑least‑once delivery, key operational checks, and failure‑mode handling to keep memory usage under control.
21 Apr 2026, 15:49 UTC

Problem and Takeaway
When you need reliable, ordered processing of messages across multiple services, Redis Streams with consumer groups give you at‑least‑once delivery without building your own queue. The key is to keep the design minimal, enforce trust boundaries, and verify that idle messages are reclaimed before they fill memory.
Requirements and Trust Boundaries
The feature set you rely on includes:
XADDto append entries with an ID.XREADGROUPto fetch new messages for a specific consumer group.XACKto confirm processing and remove entries from the pending list.XPENDINGandXCLAIMto inspect and reclaim deliveries that have been idle too long.
Trust boundaries matter: if producers or consumers run on different hosts or untrusted networks, enable requirepass and an ACL rule, or use TLS. Without authentication, any client can add or read the stream, breaking reliability guarantees.
Minimal Design
Define a single stream key (e.g., orders) and a consumer group (e.g., processor-group) with at least one consumer (e.g., worker-1). The smallest viable flow is:
- Producer runs
XADD orders * field valueto create a message. - Consumer calls
XREADGROUP GROUP processor-group worker-1 COUNT 1 BLOCK 2000 STREAMS orders >. The>ensures only new IDs are returned. - After processing, the consumer sends
XACK orders processor-group. This removes the entry from the pending list and prevents redelivery.
This pattern satisfies ordered consumption because a consumer always reads the next ID after the previous one is ACKed.
Operational Checks
Run these verification commands on a Redis instance with the appropriate permissions:
# 1. Add a test entry
redis-cli XADD orders * id 1 data "first"
# 2. Read as consumer c1
redis-cli XREADGROUP GROUP processor-group c1 COUNT 1 BLOCK 2000 STREAMS orders >
# 3. Acknowledge
redis-cli XACK orders processor-group 1
# 4. Verify pending list is empty
redis-cli XPENDING orders processor-group
If step 4 returns an empty list, the message was successfully removed. To test reclamation, stop the consumer process, wait longer than the group’s idle threshold (default 10 seconds), then run:
redis-cli XCLAIM orders processor-group c1 0 10000 1 STREAMS orders 0
The command transfers any deliveries idle for more than 10 seconds to c1. Confirm with XPENDING that the message is now listed under c1 and that the original consumer’s pending count drops.
Failure Modes
Two common failure modes affect correctness:
- Unacknowledged deliveries: If a consumer crashes before
XACK, the entry stays in the per‑consumer Pending Entries List (PEL). Over time the PEL can grow, consuming memory and causing repeated redelivery of the same payload. - Duplicate processing:
XCLAIMmay deliver the same message to a second consumer if the idle threshold is lower than the actual processing latency plus network jitter. This leads to double‑effects unless your handler is idempotent.
Mitigation:
- Set the idle threshold high enough (processing time + network jitter + safety margin).
- Make message handlers idempotent or deduplicate by the message ID.
- Monitor
XPENDINGandXINFO STREAMto detect abnormal backlogs.
Redesign Triggers
The minimal design works until one or more of the following conditions appear:
- Memory pressure: the PEL accumulates because consumers fail to ACK, and
MAXLENtrimming does not bound the pending list. Consider a dedicated memory‑limit policy or move to a compact log if exact trimming is required. - Exactly‑once semantics are needed: Redis Streams guarantee at‑least‑once delivery; if your application cannot tolerate duplicates, you must add external deduplication or switch to a system with transactional logs.
- Cross‑stream or multi‑shard processing: when you need to coordinate work across multiple streams or shards, the single‑stream model becomes insufficient, prompting a redesign toward a distributed log or a different messaging system.
When any of these triggers appear, evaluate whether adding a compensating mechanism (e.g., periodic XTRIM with MINID, introducing a dead‑letter stream, or adopting a different database) is simpler than re‑architecting the whole pipeline.
Practical Verification Checklist
- Confirm unauthenticated clients cannot
XADDorXREADGROUPby testing withredis-cli -a "". - Validate that
XACKremoves entries fromXPENDINGand thatXINFO STREAMstill shows the entry in the main stream. - Simulate a crash: stop the consumer, wait longer than the idle threshold, then run
XCLAIMand verify the message appears in the new consumer’s pending list. - Measure memory growth: run
INFO memorybefore and after a day of normal traffic; a steady increase inused_memory_humanthat outpacesmaxmemoryindicates PEL bloat.
Conclusion
Redis Streams with consumer groups provide a lightweight, ordered, and recoverable messaging layer when you keep the design minimal, enforce authentication, and actively manage idle deliveries. By regularly checking pending lists, setting appropriate claim thresholds, and ensuring idempotent processing, you avoid memory leaks and duplicate side effects. If your workload outgrows these safeguards, the redesign triggers listed above guide you toward a more robust architecture.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.