publish-subscribe
A messaging pattern where senders publish messages to a named channel and every subscriber listening on that channel receives a copy.
In more detail
Publishers do not need to know who is listening, and subscribers can come and go. It is used for broadcasting events such as cache invalidations or chat messages.
Example
A server publishes “evict item 1” on a Redis channel and every instance drops it from its local cache.Related terms
- Redis — A very fast in-memory data store used for shared caches, rate-limit counters, session data and pub/sub messaging.
- cache invalidation — Marking cached copies as out of date, or deleting them, when the real data changes so the next read fetches fresh data.
- broker — A server that receives messages from producers, stores them and delivers them to consumers, such as RabbitMQ or Apache Kafka.
- event — A message stating a fact that already happened, such as order placed, for anyone who cares to react.
- topic — A named channel in a publish-subscribe messaging system that producers write to and any number of subscribers read from.
Taught in
- Bidirectional WebSockets: Reconnection & Heartbeats — Production Full-Stack Engineering
- Distributed Cache Invalidation: Redis & Tagged Purging — Production Full-Stack Engineering
- The Difference Between A Queue And A Log — Scalable System Design & Distributed Architecture