Databases 11 min read

Redis Overview: Features, Data Types, Caching Strategies, Performance, Persistence, Replication, and Sentinel

This article provides a comprehensive introduction to Redis, covering its core characteristics, supported data structures, common caching use‑cases and associated challenges such as consistency, cache avalanche, penetration and breakdown, as well as performance reasons, eviction policies, persistence options, master‑slave replication, and Sentinel high‑availability mechanisms.

IT Architects Alliance
IT Architects Alliance
IT Architects Alliance
Redis Overview: Features, Data Types, Caching Strategies, Performance, Persistence, Replication, and Sentinel

Redis is an open‑source, high‑performance, in‑memory key‑value store written in C, often used as a database, cache, or message broker, and belongs to the NoSQL family.

Redis Characteristics

Excellent performance with data stored in memory, supporting up to 100k QPS.

Single‑threaded, thread‑safe architecture using I/O multiplexing.

Can serve as a distributed lock.

Supports five primary data types.

Provides persistence to disk.

Can be used as a message middleware with publish/subscribe.

Data Types

Redis offers five data structures, each suited to different scenarios (illustrated in the original table).

Caching with Redis

In Spring Boot, Redis is typically used either directly via RedisTemplate or through Spring Cache annotations.

Common Cache Problems

1. Data Consistency

In distributed systems, cache‑database consistency is hard to guarantee; strategies include cache‑update mechanisms and retry policies.

2. Cache Avalanche

When the cache layer fails, all traffic hits the database, potentially causing overload; mitigation involves high‑availability setups, local caches, rate limiting, and graceful degradation.

3. Cache Penetration

Requests for non‑existent keys bypass the cache and hit the database; solutions include request validation, blacklisting invalid keys, and using Bloom filters.

4. Cache Breakdown

Hot keys expiring simultaneously cause a surge of database queries; solutions depend on data change frequency, such as never expiring hot data, using distributed locks, or proactive cache rebuilding.

Why Redis Is Fast

HashMap‑like O(1) operations with in‑memory data.

Simple KV data structures.

Single‑threaded model avoids lock contention and context switches.

Non‑blocking I/O with multiplexing.

Eviction Policies

volatile* – evicts only expired keys.

allkeys* – evicts any key.

LRU – least recently used.

LFU – least frequently used.

Triggered when memory usage reaches a configured threshold.

Persistence

RDB : snapshotting the dataset to a dump file at intervals.

AOF : appending every write command to a log file; slower but more durable.

Both can be enabled simultaneously, with AOF taking precedence on restart.

Master‑Slave Replication

Slave sends SLAVEOF to specify master.

Slave establishes a socket connection to the master.

Ping/Pong messages verify connectivity.

Master sends a full data sync to the slave.

Subsequent writes are streamed from master to slaves.

Sentinel Mode

Sentinel addresses the limitations of basic replication by providing monitoring, notifications, automatic failover, and configuration services, ensuring high availability without manual intervention.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

redisPersistenceReplicationIn-Memory Database
IT Architects Alliance
Written by

IT Architects Alliance

Discussion and exchange on system, internet, large‑scale distributed, high‑availability, and high‑performance architectures, as well as big data, machine learning, AI, and architecture adjustments with internet technologies. Includes real‑world large‑scale architecture case studies. Open to architects who have ideas and enjoy sharing.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.