Messaging for Rediss
Messaging in Redis means passing data between processes using pub/sub, lists and streams, and coordinating work across servers. Pub/sub broadcasts messages without storing them, while streams keep an append-only log with consumer groups. Distributed locks and similar tools help several services agree on who does a task.
Stage: Patterns · Part of the Redis roadmap · Last reviewed 19 November 2026
What to learn in Messaging
- Publish and subscribe to a channel and note that messages are not stored
- Append events with XADD and read them with XREAD
- Process a stream with a consumer group and acknowledge entries with XACK
- Recover unacknowledged messages after a consumer crashes
- Acquire a lock with SET NX PX and release it safely
Messaging interview questions
What is the difference between Redis pub/sub and streams?
Pub/sub is fire and forget: subscribers only receive messages sent while they are connected, and nothing is kept. Streams persist entries in a log, support consumer groups, track which messages were acknowledged and let a consumer resume after a restart. Use streams when delivery matters.
Why must a distributed lock have an expiry?
If the process holding a lock crashes, a lock without a TTL would stay forever and block everyone. Setting SET key value NX PX makes it expire. The value should be a unique token, so only the owner can delete it, which is usually checked in a small Lua script.
Where Messaging fits in the Redis roadmap
Messaging belongs to the Patterns stage (intermediate level), which takes about 12 hours. What Redis is used for.
Other units in this stage
Back to the full Redis roadmap