Redis Mind Map: A Complete Mental Model of Redis Architecture

Learn Redis architecture with a complete beginner-friendly mental model covering event loop, replication, Redis Cluster, sharding, persistence, failover, Pub/Sub, Streams, and scaling in production systems.

Ashutosh Verma30 May 2026 Β· 6 min read
Share

🎯 Big picture of how Redis actually works internally and scales in production systems.


The One Thing That Makes Redis Different

Most databases are:

text
Disk First

Redis is:

text
RAM First

That single design decision changes everything.

Because Redis stores data directly in memory:

  • reads become insanely fast
  • writes become insanely fast
  • latency becomes microseconds
  • real-time systems become possible

That is why:

  • gaming systems
  • trading platforms
  • chat systems
  • food delivery apps
  • notification systems

heavily use Redis.


The Core Redis Flow

Redis internally looks like this:

text
Clients
   ↓
TCP Connections
   ↓
Redis Event Loop
   ↓
Command Execution
   ↓
RAM Data Structures
   ↓
(Optional Persistence)

Every Redis concept builds on this flow.


The Event Loop β€” The Heart of Redis

This is the part that confuses most beginners.

People hear:

text
"Redis is single threaded"

and imagine Redis is slow.

Actually Redis is fast BECAUSE of this.


Traditional Servers

Traditional servers often work like:

text
1 request
↓
1 thread

More users:

  • more threads
  • more locks
  • more context switching
  • more synchronization overhead

Eventually CPU wastes time managing threads.


Redis Takes Opposite Approach

Redis uses:

text
One main event loop

that continuously handles:

  • connections
  • reads
  • writes
  • command scheduling

Commands execute:

  • sequentially
  • one-by-one
  • extremely fast

Example:

text
Client1 β†’ GET user
Client2 β†’ SET order
Client3 β†’ INCR counter

Redis processes:

text
GET
SET
INCR

one at a time.


Then Why Is Redis Still So Fast?

Because Redis operations are tiny.

Most operations:

  • hash lookups
  • memory reads
  • counter increments

take:

text
microseconds

not milliseconds.

Redis avoids:

  • locks
  • thread fights
  • race conditions
  • synchronization delays

So even sequential execution becomes extremely fast.

That is the Redis superpower.


Redis Is Actually a Data Structure Engine

Most people think Redis is:

text
just cache

Wrong.

Redis is really:

text
A Data Structure Server

Strings

Used for:

  • cache
  • OTP
  • counters

Hashes

Used for:

  • profiles
  • session objects
  • carts

Lists

Used for:

  • queues
  • feeds
  • job systems

Sets

Used for:

  • unique values
  • tags
  • followers

Sorted Sets

One of Redis's most powerful structures.

Used for:

  • leaderboards
  • rankings
  • priority systems

Streams

Redis Streams transformed Redis from:

text
cache

into:

text
event streaming system

Very similar to lightweight Kafka.


But RAM Has One Huge Problem

RAM is volatile.

Machine restart:

text
everything disappears

So Redis needed persistence.


Redis Persistence

Redis solves this in two ways.


RDB Snapshots

Redis periodically creates full snapshots.

Mental model:

text
RAM
 ↓
Fork Child Process
 ↓
Generate Snapshot
 ↓
Save .rdb File

Fast. Compact. Good recovery.

But latest writes may be lost.


AOF (Append Only File)

Instead of snapshots:

Redis logs every write command.

text
SET user John
INCR views
DEL cache

Now Redis can replay operations during restart.

Safer. But larger and slower.


Production Systems Usually Use Both

Because:

  • RDB gives fast recovery
  • AOF gives durability

Eventually One Redis Server Stops Being Enough

Single Redis node eventually hits limits:

text
RAM full
CPU saturated
network saturated

Now Redis must scale horizontally.

This is where Redis Cluster begins.


Redis Cluster Changes Everything

Instead of:

text
One giant Redis

we now have:

text
Many Redis nodes

working together.

Example:

text
Node1
Node2
Node3
Node4
Node5

Each node stores:

text
partial data

This is called:

Sharding


Redis Sharding Model

Redis Cluster internally creates:

text
16384 hash slots

Every key belongs to one slot.

Flow:

text
Key
 ↓
CRC16 Hash
 ↓
Hash Slot
 ↓
Correct Redis Node

Example:

text
user:1
 ↓
slot 5000
 ↓
Node2

Important Thing

Application developers NEVER manually choose nodes.

Redis client handles:

  • hashing
  • routing
  • topology discovery

automatically.

Your code still looks simple:

text
GET
SET
DEL

even though internally:

text
20 Redis servers

may exist.


Redis Nodes Must Communicate Too

Clustered Redis nodes constantly exchange metadata.

For this Redis uses:

Cluster Bus

Usually:

text
6379  β†’ client traffic
16379 β†’ cluster communication

Nodes continuously gossip:

  • who is alive
  • who failed
  • slot ownership
  • replica info

This is called:

Gossip Protocol

Every node gradually learns full cluster topology.


Replication Makes Redis Highly Available

Sharding alone is not enough.

If one node dies:

text
data gone

So Redis adds replicas.

Example:

text
Master1 β†’ Replica1
Master2 β†’ Replica2
Master3 β†’ Replica3

Writes go to:

text
masters

Replicas continuously copy updates.


What Happens During Failure?

Suppose:

text
Master2 dies

Other nodes detect failure using:

text
heartbeat timeout

Replica election starts.

Replica promoted automatically.

Now cluster heals itself.

This is why Redis feels highly available.


Scaling Redis Cluster

As traffic grows:

text
add more Redis nodes

Redis automatically:

  • redistributes slots
  • migrates keys
  • updates topology

without shutting down cluster.

This process is called:

Resharding


Redis Is Not Only Cache Anymore

Modern Redis powers:

  • chat systems
  • websocket state
  • leaderboards
  • event systems
  • queues
  • gaming
  • real-time analytics

Redis became:

text
real-time infrastructure layer

for modern applications.


Pub/Sub vs Streams

Redis supports two messaging models.


Pub/Sub

text
Publisher
   ↓
Channel
   ↓
Subscribers

Fast. Realtime. But messages disappear if subscriber offline.


Streams

Persistent event log.

Supports:

  • replay
  • ACKs
  • consumer groups

Much closer to Kafka architecture.


Final Redis Mental Model

Redis internally is:

text
RAM-first
event-driven
single-threaded execution
distributed
real-time optimized

And Redis scales using:

text
Sharding
+
Replication
+
Cluster Gossip
+
Automatic Failover
+
Event Loop Architecture

while keeping application code extremely simple.

That simplicity is why Redis became one of the most important backend infrastructure tools in modern engineering.