Skip to main content

Command Palette

Search for a command to run...

Redis Pub/Sub Durability

Updated
1 min read
Redis Pub/Sub Durability

Introduction

Redis, by default, is not durable for Pub/Sub messages, meaning messages can be lost if a Redis instance crashes or subscribers are offline. However, Redis offers various persistence options like AOF (Append Only File) and snapshots (RDB) for durable storage of its data, including streams.

Looking Deeper

  • Redis Pub/Sub:

    Redis Pub/Sub is an in-memory messaging system. If a publisher sends a message to a channel and no subscribers are actively listening, or if the Redis server crashes, the message is lost.

  • Redis Streams:

    Redis Streams provide a more robust way to handle message sequences, but they still rely on the persistence settings of the Redis instance. They don't inherently guarantee message durability and have limited retention.

Persistence Options:

Redis offers two main persistence mechanisms:

  • AOF (Append Only File): AOF logs every write operation to disk, providing better durability than snapshots.
  • RDB (Redis Database): RDB creates point-in-time snapshots of the data, which can be faster to load but may lead to data loss if the server crashes between snapshots.
  • Hybrid Persistence:

    Redis allows using both AOF and RDB simultaneously for a balance of performance and durability.

Conclusion

To ensure durability for streams or other data in Redis, it's crucial to configure persistence (AOF, RDB, or both) and potentially use other techniques like replication and failover for high availability.

More from this blog

Cloud Tuned

623 posts

Your starting point for anything cloud: AWS, Azure, GCP, Serverless, Architecture, Hybrid Cloud, Systems Design and other Information Technology topics.