Append-only log with consumer groups. Persistent alternative to Pub/Sub.
Basics¶
XADD events * type click user_id 123
XRANGE events - + COUNT 10
XLEN events
Consumer Groups¶
XGROUP CREATE events mygroup $ MKSTREAM
XREADGROUP GROUP mygroup consumer1 COUNT 5 BLOCK 2000 STREAMS events >
XACK events mygroup 1234567890-0
Advantages vs Pub/Sub¶
- Persistence
- Consumer groups
- Acknowledgment
- Replay
Practical Deployment¶
Redis Streams are ideal for applications that need reliable event streaming without the complexity of Kafka. Consumer groups allow distributing processing across multiple workers — each message is delivered to only one consumer in the group. XACK confirms successful processing, and unacknowledged messages can be re-read using XPENDING and XCLAIM.
Typical use cases include event sourcing, activity feeds, audit logs, and task queues. Unlike List-based queues (LPUSH/BRPOP), Streams offer ID-based access, automatic trimming with MAXLEN, and the ability to replay the entire history. For small to medium volumes (thousands of messages per second), Streams are an excellent alternative to Kafka with significantly simpler operations. For high-volume scenarios (millions of messages/s), Kafka remains the better choice.
Streams = Kafka-lite¶
Sufficient for most use cases instead of Kafka.