Databases 11 min read

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

This article provides a comprehensive overview of Redis, covering its core characteristics, supported data types, common caching challenges such as consistency, avalanche, penetration and breakdown, as well as its high performance mechanisms, eviction policies, persistence options, master‑slave replication, and Sentinel high‑availability architecture.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Redis Overview: Features, Data Types, Caching Issues, Performance, Persistence, Replication, and Sentinel

1. Introduction to Redis

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

2. Redis Characteristics

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

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

Can serve as a distributed lock.

Supports five data structures.

Provides persistence to disk.

Can be used as a message middleware with pub/sub.

3. Data Types

The following image illustrates the five data types and their typical use cases.

4. Caching

Caching is the primary scenario for Redis, designed specifically for it.

5. Common Caching Problems

(1) Data Consistency

In distributed environments, cache and database can become inconsistent; strong consistency should be avoided for cache, and strategies such as cache‑update after DB write or retry mechanisms are used.

(2) Cache Avalanche

A cache avalanche occurs when a cache node fails and all traffic falls onto the database, overwhelming it. Mitigation includes high‑availability setups (master‑slave + Sentinel, clustering), local Ehcache with rate limiting, and persistence for quick recovery.

(3) Cache Penetration

When requests target keys that are absent in both cache and DB, attackers can overload the database. Solutions include request‑level validation, Bloom filter checks, and storing negative results in Redis.

(4) Cache Breakdown

When a hot key expires, a massive burst of requests may hit the database simultaneously. Mitigation varies by data change frequency: set never‑expire for static data, use distributed locks for infrequent updates, or pre‑warm/refresh caches for frequently changing data.

6. Why Redis Is So Fast

Uses a HashMap‑like structure with O(1) operations, all in memory.

Simple KV data model.

Single‑threaded design eliminates lock contention and context switches.

Non‑blocking I/O with multiplexing.

7. Eviction Policies

volatile* – evicts only expired keys.

allkeys* – evicts from the entire keyspace.

LRU – Least Recently Used.

LFU – Least Frequently Used.

All policies trigger when Redis memory reaches the configured threshold.

8. Persistence

Redis offers two persistence mechanisms:

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

AOF : Appending every write command to a log file.

RDB is fast for backup and recovery, while AOF provides finer‑grained durability at the cost of write performance. Both can be enabled simultaneously, with AOF taking precedence on restart.

9. Master‑Slave Replication

Slave runs slaveof [masterIP] [masterPort] to record master info.

Slave periodically connects to master via socket.

Ping/Pong messages verify connectivity.

Master sends full data for initial sync, then streams write commands.

10. Sentinel Mode

Master‑slave replication faces issues such as manual failover and limited write capacity. Sentinel provides:

Monitoring of master and slaves.

Notification via API scripts.

Automatic failover: promotes a slave to master when needed.

Configuration provider: clients query Sentinel for current master address.

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.

performancerediscachingPersistenceReplicationsentinelIn-Memory Database
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

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.