Redis Mastery: In‑Depth Overview of Redis Internals, Persistence, Replication, and Sentinel
This article introduces the new Redis book "Redis Mastery", explains core Redis concepts such as SDS strings, RDB/AOF persistence, master‑slave replication and Sentinel high‑availability, and also announces a limited‑time discount and giveaway for community members.
Redis is a popular in‑memory database known for its outstanding performance and wide range of use cases.
The article presents the newly released book "Redis Mastery" (《Redis高手心法》), which blends complex concepts with practical examples in a concise, humorous style.
1. Book Highlights
Each chapter is carefully crafted, covering Redis data structures, RDB/AOF persistence, master‑slave replication, and Sentinel high‑availability, accompanied by 158 illustrations.
1.1 Underlying Data Structures
Redis provides data types such as String, Hash, List, Set, Sorted Set, Bitmap, HyperLogLog, Geospatial, and Stream. It uses a custom Simple Dynamic String (SDS) implementation instead of the native C string. The SDS header is defined as:
struct __attribute__((packed)) sdshdr8 {
uint8_t len;
uint8_t alloc;
unsigned char flags;
char buf[];
};SDS stores the string length in O(1) time, offers five header variants to save memory, and can hold binary data safely.
1.2 RDB and AOF Persistence
Redis offers two durability mechanisms: RDB snapshots and Append‑Only File (AOF). Snapshots are created using copy‑on‑write (COW) so writes continue uninterrupted, while AOF rewrite and the newer Multi‑Part AOF reduce log size and improve recovery speed.
1.3 Master‑Slave Replication
Replication consists of a full synchronization phase, incremental command propagation during normal operation, and reconnection handling after network interruptions. The process is illustrated with a three‑stage diagram covering connection, data transfer, and command streaming.
1.4 Sentinel Cluster
Sentinel monitors master and slave instances, detects failures, performs automatic leader election, and switches slaves to become the new master, ensuring high availability without manual intervention.
2. Promotion
The book is offered at a 50% discount (price reduced from 100 to 50 "ling stones") and a limited‑time giveaway of three copies for users who follow the AikeSheng Open‑Source Community public account and complete the listed tasks.
3. Endorsements and Resources
Several IT experts have praised the book. Links to the project's GitHub repository, documentation site, official website, community chat, and commercial support are provided.
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.