Skip to main content
PreparationZone Logo
PrepZone

Redis Pub/Sub and Streams

Fire-and-forget messaging vs durable consumer groups for event pipelines.

Pass checkpoint below

Why this matters

  • Checkout emits events (payment captured, shipment queued) that multiple services must consume — Streams give durability and at-least-once delivery; Pub/Sub does not.
  • Confusing the two causes lost messages during deploys or network blips when nobody was subscribed.
  • Redis Streams are lighter than Kafka for moderate throughput but still require explicit consumer-group design.
StringSessions, counters
ListQueues, feeds
SetUnique tags
Sorted SetLeaderboards
HashUser profiles
StreamEvent log
Each type maps to a common backend pattern.

Pub/Sub: live notifications

Publishers send to channels; subscribers receive messages in real time. No persistence, no replay, no acks.

Java
SUBSCRIBE order:updates
# separate terminal:
PUBLISH order:updates "{\"orderId\":\"9001\",\"status\":\"SHIPPED\"}"
PSUBSCRIBE inventory:*
PUBLISH inventory:SKU-8842 "restocked"

VaultCommerce pushes "your order shipped" toast notifications to connected browsers via a WebSocket gateway subscribed to order:{userId} channels. If the gateway restarts, missed messages are acceptable — the user refreshes and reads Postgres.

Pub/Sub characteristics

  • Ephemeral — no message history; offline subscribers miss data.
  • Fan-out — every subscriber on the channel receives a copy.
  • Low latency — ideal for live dashboards and typing indicators.
  • No ordering guarantees across channels.

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 2 sections

  • Streams: durable event log
  • VaultCommerce order pipeline

Test yourself

Answer these before moving on — recall is what makes it stick.