database/redis distributedsystem systemdesign
Redis for Beginners
TOC
- Redis Explained
- Redis Underlying Data Structures
- Redis Serialization Protocol(RESP)
- Redis PubSub and Implementation
- Redis Queue
- Redis Reliable Queue Pattern
- Redis Data Persistence
- Redis HSET, EXPIRE & TTL
- Redis Streams
- Redis Geospatial
- Redis Sorted Sets
- Redis Sentinal
- Redis Cluster
- Redis Hyperloglog
How to Use Bloom Filters in Redis
Introduction
Redis (βREmote DIctionary Serviceβ) is an open-source key-value database server.

Transclude of row-based-and-column-based-database#memory-vs-disk-based-databases
Queues, Pub/sub, and Streams
| Feature | Redis Queue aka Redis List | Redis Pub/Sub | Redis Streams |
|---|---|---|---|
| Purpose | Task/job scheduling and background processing. | Real-time messaging between publishers and subscribers. | Real-time data processing with persistence and consumer groups. |
| Data Model | FIFO (First In, First Out) queue. | Publish-subscribe messaging system. | Append-only log of key-value pairs. |
| Persistence | No inherent persistence; tasks are lost if not processed before a crash. | No persistence; messages are lost if subscribers are offline. | Persistent; entries remain in the stream until explicitly trimmed. |
| Scalability | Can distribute jobs across multiple workers for horizontal scaling. | Scales well with a large number of publishers and subscribers. | Supports multiple consumers via consumer groups for distributed processing. |
| Reliability | Supports job retries, prioritization, and dependencies for reliable task execution. | Fire-and-forget; no guarantees on message delivery or retries. | Provides at-least-once delivery with acknowledgment mechanisms for reliability. |
| Use Cases | - Background job processing - Task scheduling - Distributed workloads - Job prioritization and dependencies. | - Real-time notifications - Chat applications - Live updates - Event broadcasting. | - IoT data ingestion - Real-time analytics - Message brokering - Logging/audit trails. - Activity feeds. |
| Consumer Model | Workers explicitly pull tasks from the queue (pull-based). | Subscribers passively receive messages when published (push-based). | Consumers actively read entries from the stream; consumer groups enable parallel processing (pull-based). |
| Message Retention | Tasks remain in the queue until processed or manually deleted. | Messages are ephemeral and only delivered to active subscribers at the time of publishing. | Messages persist in the stream until explicitly trimmed or expired based on retention policies. |
Redis High Availability
High Availability (HA) in Redis ensures that the database remains operational even if some nodes fail. It is crucial for applications that require minimal downtime and data consistency.
08 - ESB & ASG > Scalability & High Availability
Redis provides two primary HA solutions:
- Redis Sentinal β Provides automatic failover but does NOT support Database Sharding.
- Redis Cluster β Provides both failover and data sharding for scalability.
Redis Sentinel Vs. Redis Cluster
Redis Sentinel vs Clustering | Baeldung
| Feature | Redis Sentinel | Redis Cluster |
|---|---|---|
| Purpose | Automatic Failover | Failover + Data Sharding |
| Data Sharding | β No | β Yes |
| Replication | β Master-Replica | β Master-Replica |
| Failover Handling | β Yes | β Yes |
| Minimum Nodes | At least 3 Sentinels | At least 3 Masters + Replicas |
| Best For | Failover & HA only | Scalability + HA |