Pub/Sub & Streaming

6 production-ready cookbooks for real-time messaging with Valkey. From basic PUBLISH/SUBSCRIBE to distributed consumer groups with Valkey Streams.

┌──────────────┐ ┌───────────────┐ ┌──────────────┐ │ LLM Service │ │ Valkey │ │ Client A │ │ (Producer) │────▶│ Pub/Sub or │────▶│ (Subscriber)│ │ │ │ Streams │ └──────────────┘ └──────────────┘ │ │ ┌──────────────┐ │ PUBLISH / │────▶│ Client B │ │ XADD │ │ (Subscriber)│ └───────────────┘ └──────────────┘
01

Getting Started with Pub/Sub

PUBLISH, SUBSCRIBE, and pattern matching. Your first real-time message in under 5 minutes.

Beginner~5 minPython
02

Streaming LLM Tokens

Buffer and broadcast token-by-token LLM responses to multiple clients via Pub/Sub.

Intermediate~15 minPython
03

Valkey Streams Fundamentals

XADD, XREAD, and XRANGE for durable, ordered message queues. Pub/Sub vs Streams - when to use which.

Intermediate~20 minPython
04

Consumer Groups

Distributed stream processing with XREADGROUP, acknowledgments, pending entries, and dead-letter handling.

Advanced~25 minPython
05

Fan-Out Patterns

One producer → many consumers. Multi-client delivery for AI agent events, notifications, and real-time dashboards.

Advanced~25 minPython
06

Production Patterns

Backpressure with MAXLEN, monitoring with XINFO, reconnection strategies, and scaling patterns.

Advanced~30 minPython

🎮 Try It Live

Interactive Pub/Sub & Streams dashboard - publish messages, subscribe to channels, and see real-time delivery.

Open Interactive Demo
⭐ View on GitHub