Command Palette

Search for a command to run...

Hectal
Phase 5Intermediate6 of 17 in Redis

Messaging: Pub/Sub, Streams & Notifications

Fire-and-forget Pub/Sub, durable Streams with consumer groups, how they compare to lists, Kafka and RabbitMQ, and the notification features behind client-side caching.

Redis has three messaging models with very different guarantees. Pub/Sub delivers to whoever is listening right now and forgets. Lists hand a message to one consumer. Streams keep an append-only log with consumer groups, acknowledgements and replay.

Senior interviews probe exactly the gaps between them: what happens when a subscriber disconnects, how a crashed consumer's messages get retried, and when Redis should hand over to Kafka.

0/5 · 0%
5 topics ~52 min 11 code blocks & diagrams
Start with the first topic
1
5.1

Pub/Sub: Real-Time, At-Most-Once Messaging

PUBLISH sends a message to every client currently subscribed to a channel, and then forgets it. It's ideal for live notifications and cache invalidation broadcasts, and wrong for anything that must survive a disconnect, because there's no storage, no acknowledgement and no replay.

10 min 1 diagram 1 code practice

2
5.2

Streams: An Append-Only Log in Redis

A stream is an append-only log of entries, each with a time-based ID and field-value pairs. You append with XADD, read ranges with XRANGE, tail it with XREAD BLOCK, and cap it with MAXLEN or MINID. Unlike Pub/Sub, entries stay until you trim them, so readers can catch up.

10 min 1 diagram 1 code practice

3
5.3

Consumer Groups: Acks, Pending Entries, and Recovery

A consumer group splits a stream's entries among workers, tracks what each has received but not yet acknowledged in the Pending Entries List (PEL), and lets healthy workers claim a crashed worker's messages with XAUTOCLAIM. That gives at-least-once processing, so handlers must be idempotent.

13 min 1 diagram 2 code practice

4
5.4

Choosing a Queue: Lists, Streams, Pub/Sub, Kafka, RabbitMQ

Pick a messaging tool by its guarantees: whether messages persist, whether they're acknowledged, whether they can be replayed, how consumers scale, and how much operational weight you can carry. Redis covers low-latency and moderate-durability cases; Kafka and RabbitMQ cover durable logs and rich routing.

9 min 1 code practice

5
5.5

Keyspace Notifications and Client-Side Caching

Keyspace notifications publish events when keys change or expire, useful for reacting to changes but fire-and-forget. Client-side caching (CLIENT TRACKING) lets apps keep hot keys in local memory while Redis sends invalidation messages when those keys change: a near-cache with server-assisted consistency.

10 min 1 diagram 2 code practice