100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Redis

Redis Pub/Sub

Learn how Redis's publish/subscribe messaging model works, its fire-and-forget delivery guarantees, and when to reach for Streams instead.

Key ManagementIntermediate9 min readJul 10, 2026
Analogies

The Publish/Subscribe Model

Redis Pub/Sub lets clients subscribe to named channels with SUBSCRIBE channel-name, and any client can broadcast a message to every current subscriber of that channel with PUBLISH channel-name message. There is no persistence involved: Redis does not store messages anywhere, does not queue them for offline subscribers, and does not track delivery. A message published to a channel with zero active subscribers simply vanishes; PUBLISH returns the count of clients it was delivered to, which can legitimately be zero.

🏏

Cricket analogy: Pub/Sub is like a stadium's live PA announcer calling out a score update — anyone in the stadium at that exact moment hears it, but if you walk in five minutes later you've missed that announcement entirely, there's no replay booth storing it for you.

bash
# Terminal 1: subscribe to a channel
SUBSCRIBE notifications:order-updates
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "notifications:order-updates"
3) (integer) 1

# Terminal 2: publish a message
PUBLISH notifications:order-updates '{"orderId":8821,"status":"shipped"}'
(integer) 1

# Back in Terminal 1, the message arrives:
1) "message"
2) "notifications:order-updates"
3) "{\"orderId\":8821,\"status\":\"shipped\"}"

# Pattern-based subscription across multiple channels
PSUBSCRIBE "notifications:*"

Pattern Subscriptions and Channel Fan-Out

PSUBSCRIBE pattern lets a client subscribe using a glob-style pattern such as notifications:* to receive every message published to any channel matching that pattern, without needing to know every exact channel name in advance. This is useful for building generic dispatchers, for example a single logging or audit subscriber that listens to events:* across dozens of dynamically-named channels like events:user:42 and events:order:8821. Each matching client still receives its own independent copy of every message — PUBLISH fans a message out to all subscribers simultaneously; it is not a work queue where only one subscriber consumes each message.

🏏

Cricket analogy: PSUBSCRIBE is like a broadcaster subscribing to 'every match involving India' rather than naming each fixture individually — as new India fixtures get scheduled, the broadcaster automatically picks up coverage without re-subscribing to each one by name.

Fire-and-Forget: No Durability

Because Pub/Sub messages are never written to disk or replicated as data, a subscriber that's disconnected, restarting, or simply slow to process incoming messages will permanently miss anything published during that window; reconnecting only resumes receiving new messages from that point forward. Redis also does not implement consumer groups, acknowledgments, or message replay for Pub/Sub — it is fundamentally a broadcast mechanism for ephemeral, real-time notifications, not a durable message queue, and using it as one is a common and costly architectural mistake.

🏏

Cricket analogy: This is like missing a live stadium PA update because you stepped out to the concession stand — when you return, the PA doesn't repeat what you missed, it just continues broadcasting whatever happens next.

Never use Pub/Sub for data that must not be lost, such as order events that drive billing, or notifications a user absolutely must eventually receive. If you need at-least-once delivery, consumer groups, message replay, or durability across subscriber restarts, use Redis Streams (XADD/XREAD/XREADGROUP) instead, which persists messages in a log-like structure and supports acknowledgment-based consumption. Pub/Sub is the right tool only when losing a message during a disconnect is an acceptable trade-off, such as live cache-invalidation broadcasts or ephemeral presence updates.

Common Use Cases and Cluster Behavior

Typical legitimate uses include broadcasting cache-invalidation events to multiple application server instances so they can drop a local in-memory cache entry the instant it changes upstream, powering real-time features like live chat typing indicators or live dashboard updates where only the most current state matters, and implementing keyspace notifications, where Redis itself publishes events like expired or set to a special channel whenever a key changes, letting applications react to Redis-internal events. In Redis Cluster mode, regular PUBLISH/SUBSCRIBE messages are broadcast to every node in the cluster regardless of which node the publishing or subscribing client is connected to, while SPUBLISH/SSUBSCRIBE (sharded Pub/Sub, added in Redis 7) restrict propagation to the shard owning the channel's hash slot, reducing cross-node broadcast overhead for high-throughput use cases.

🏏

Cricket analogy: Cache invalidation broadcasts are like a stadium's giant screen operator instantly refreshing the scoreboard the moment DRS overturns a decision, so every screen around the ground updates in sync rather than each screen operator independently deciding when to refresh.

Redis's built-in keyspace notifications must be explicitly enabled with CONFIG SET notify-keyspace-events (they're off by default for performance reasons), and once enabled, Redis publishes to channels like __keyspace@0__:mykey and __keyevent@0__:expired so applications can subscribe to react to expirations, deletions, or other key events in real time.

  • PUBLISH broadcasts a message to every current subscriber of a channel; there is no storage, queuing, or delivery tracking.
  • A message published to a channel with no active subscribers is simply discarded; PUBLISH can legitimately return 0.
  • PSUBSCRIBE allows glob-pattern subscriptions across multiple channels without knowing every exact channel name upfront.
  • Pub/Sub is fire-and-forget: disconnected or slow subscribers permanently miss messages published during that window.
  • Redis Streams (XADD/XREAD/XREADGROUP) should be used instead when durability, replay, or consumer groups are required.
  • Keyspace notifications let Redis itself publish events like expired or set, but must be enabled via CONFIG SET notify-keyspace-events.
  • In Cluster mode, plain PUBLISH broadcasts cluster-wide, while SPUBLISH/SSUBSCRIBE (Redis 7+) scope propagation to a single shard.

Practice what you learned

Was this page helpful?

Topics covered

#Redis#RedisStudyNotes#Database#RedisPubSub#Pub#Sub#Publish#Subscribe#StudyNotes#SkillVeris

Frequently Asked Questions

21 categories · pick one to explore

Where can I get free study notes for programming and tech subjects?
SkillVeris offers completely free study notes covering programming and tech subjects, with no signup fees or paywalls. The notes are structured by course and topic, written for quick understanding, and enriched with the Learn Through Hobbies analogy method, so you can revise concepts through cricket, music, gaming, cooking and more.
Are SkillVeris study notes good for exam revision?
Yes, the study notes are designed for efficient revision: each topic answers its heading immediately, keeps explanations concise, and links to related glossary terms and cheat sheets. Students preparing for university exams or certification tests use them as quick revision notes because they distil concepts without the padding of full textbooks.
What subjects do the free study notes cover?
The study notes span the platform's main domains, including AI and machine learning, Python and programming, web development, DevOps, cloud, security and databases. Coverage mirrors the 37 live courses, so notes exist for the topics you are actually studying, and new note sets are added as courses launch.
How are SkillVeris study notes different from regular textbooks?
The notes are answer-first, concise and free, whereas textbooks are long and often expensive. Each section explains one concept directly, then reinforces it through selectable hobby analogies like cricket or cooking. Notes also cross-link to the glossary, blog and cheat sheets, letting you jump to related material instantly instead of flipping pages.
Can I use the developer study material without creating an account?
The study notes are free to access, and SkillVeris does not charge anything for its developer study material at any point. Browsing notes is straightforward from the Study Notes section, and if you want progress tracking, certificates and AI Mentor conversations tied to your learning, a free account unlocks those extras.
Do the study notes explain concepts with analogies?
Yes, this is a signature SkillVeris feature. Study notes use the Learn Through Hobbies method, explaining technical concepts through analogies from twelve domains including cricket, music, gaming, photography, travel, movies, fitness, chess, cooking, finance, business and sports. You can switch the analogy domain instantly to whichever hobby makes the concept click.
Are the revision notes suitable for last-minute exam preparation?
Yes, revision notes on SkillVeris work well for last-minute preparation because every section states the answer in its first sentences, so skimming is genuinely effective. Pair them with the relevant cheat sheet for formulas and syntax, and use the glossary for any unfamiliar term you meet while cramming.
Is there free study material for AI and machine learning?
Yes, SkillVeris provides free study notes across its AI and ML catalogue, covering Python for AI, deep learning frameworks like PyTorch and TensorFlow, Hugging Face Transformers, Large Language Models, RAG, AI agents and MLOps. All of it is free, making it a strong resource for Indian students and global learners alike.
Can beginners understand the study notes, or are they for experts?
Beginners can absolutely use them. The notes are written in plain language, define terms as they appear, and lean on hobby analogies to make abstract ideas concrete. Difficulty scales with the underlying course level, so beginner-course notes stay gentle while advanced-course notes go deeper, and the glossary supports you throughout.
How do study notes connect with SkillVeris courses?
Study notes are organised by course and topic, so they map directly to the structured courses and their 24–40-lesson curriculum. Many learners study a lesson first, then use the matching notes for revision before module assessments and the final exam, where 80 percent is required to pass and earn the certificate.
Are there study notes for Python specifically?
Yes, Python is well covered through notes tied to the Python-focused courses, including Python for AI and ML. Topics span fundamentals through applied machine learning usage. You can reinforce the notes with Python practice in Code Lab, which runs code in your browser with no installation required.
Do the study notes include code examples?
Yes, study notes include code examples wherever a concept is best shown in code, alongside explanations, key points and analogies. Reading a snippet in the notes and then reproducing it yourself in Code Lab is an effective loop, since Code Lab lets you run code in the browser across six languages.
How often is new study material added to SkillVeris?
Study material grows alongside the course catalogue. Whenever new courses join the platform's 37 live courses, matching study notes, glossary entries and cheat sheets are added so the resources stay in sync. Existing notes are also refined over time, so it is worth revisiting topics you studied earlier.
Can I use SkillVeris notes to prepare for technical interviews?
Yes, the notes make excellent interview revision because they compress each concept into direct, answer-first explanations, which mirrors how you should answer interview questions. Combine them with the SkillVeris interview questions feature, which includes readiness scoring, to test whether your revision has actually made you interview-ready.
Are the study notes mobile-friendly for studying on the go?
Yes, the study notes are built to load fast and read comfortably on mobile devices, so you can revise during a commute or between classes. Sections are short and answer-first, which suits small screens, and analogy switching works on mobile too, letting you study anywhere without carrying books.
What is the difference between study notes and cheat sheets?
Study notes explain concepts in depth with context, examples and analogies, making them ideal for learning and revision. Cheat sheets are compact quick-reference summaries of syntax, commands and key facts, ideal once you already understand a topic. Most learners study the notes first, then keep the cheat sheet handy while coding.
Do study notes help if I am stuck on a course lesson?
Yes, reading the matching study notes often clarifies a lesson because the same concept is explained from a different angle, frequently with a different analogy. If you are still stuck, ask the AI Mentor, which answers 24/7 at Quick, Detailed or Deep-dive depth until the idea genuinely makes sense.
Is there free study material for DevOps and cloud topics?
Yes, SkillVeris carries free study notes for DevOps and cloud topics as part of its coverage across 37 live courses. The material suits learners following the DevOps Engineer or Cloud Engineer paths, and it links to related glossary terms and cheat sheets so you can revise the whole toolchain in one place.
Can school or college students in India use these notes for projects?
Yes, students across India and worldwide use SkillVeris notes for coursework, projects and exam preparation, and everything is free, which matters for student budgets. The notes explain concepts clearly enough to cite in project reports, and Code Lab lets you prototype the project code directly in your browser.
How should I combine study notes with other SkillVeris resources?
A proven loop: learn from a course lesson, revise with the matching study notes, look up unfamiliar terms in the glossary, keep the cheat sheet open while practising in Code Lab, and quiz yourself with interview questions. The AI Mentor fills any remaining gaps 24/7, at whatever depth you need.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse