System Design Space
Knowledge graphSettings

Updated: March 1, 2026 at 7:40 PM

Redis: in-memory database and architecture

mid

In-memory key-value system: event loop execution, data structures, durability modes (RDB/AOF), replication, Sentinel, and Redis Cluster.

Source

Wikipedia: Redis

Redis history, architecture fundamentals, and the role of in-memory storage in modern systems.

Open article

Official site

Redis

Official documentation on data structures, persistence, replication, Sentinel, and Cluster.

Open website

Redis is an in-memory key-value store with rich data structures and extremely low latency. In system design, Redis is often used as a dedicated operational layer: cache, sessions, counters, queues/streams, and fast stateful primitives for high-throughput systems.

History and context

2009

First public release

Redis appears as an open-source in-memory key-value store focused on very low latency.

2010s

Data model and use-case expansion

Beyond plain caching, Redis becomes widely used for rate limiting, queues, leaderboards, and session storage.

2013-2016

HA and scaling patterns mature

Replication, Sentinel, and Redis Cluster practices establish the baseline production approach for failover and sharding.

2020+

Cloud-first operations

Managed Redis becomes standard for many teams, shifting focus to SLA, observability, and memory cost control.

Core architecture elements

Event loop and atomic commands

Commands execute in a sequential event loop, simplifying concurrency behavior and keeping latency predictable.

In-memory data structures

Strings, Hashes, Lists, Sets, Sorted Sets, and Streams solve many workloads without a heavyweight query planner.

Durability: RDB and AOF

Redis supports multiple durability modes: snapshot persistence, append-only logging, and mixed strategies.

Replication and Cluster

Primary/replica topology, Sentinel, and hash-slot sharding in Redis Cluster provide HA and horizontal scale.

Redis Data Structures: why it is more than key/value

Redis stores typed structures and exposes specialized commands per type. This makes it more than a cache and enables practical stateful primitives with atomic operations.

Redis Data Structures: more than key/value

In Redis, a key points not just to a raw value but to a typed in-memory structure with specialized atomic commands.

Why Redis is not "just key/value"

  • Redis values are typed (String/Hash/List/Set/ZSET/Stream), not opaque blobs.
  • Server-side atomic operations reduce round-trips and simplify concurrency control.
  • Each type provides domain primitives: leaderboards, queues, counters, event feeds, approximate analytics.
  • Data structures + TTL + persistence + replication form a full operational data layer.

String

Universal type for cache entries, counters, flags, and compact JSON payloads.

Key commands

GET/SETINCR/DECRMGET/MSETEXPIRE

Typical use cases

  • Cache-aside
  • Session token
  • Atomic counters

Example

SET user:1001:profile '{"name":"Alice"}' EX 300
INCR page:home:views

High-Level Architecture

The diagram below shows a high-level Redis setup in a product system: client layer, command execution path, in-memory model, durability pipeline, and cluster/failover mechanics.

Clients and protocol
RESP2/RESP3redis-cliClient librariesTLS + ACL
Layer transition
Command processing
Event loopAtomic commandsPipeliningLua / Functions
Layer transition
In-memory data model
String/HashList/Set/ZSETStreamsProbabilistic structs
Layer transition
Persistence
RDB snapshotsAOFappendfsync policyAOF rewrite
Layer transition
Replication and failover
Primary/ReplicaPSYNCSentinelFailover
Layer transition
Cluster operations
Hash slotsReshardingEviction policyMonitoring

System view

Redis is typically used as an in-memory operational layer for low-latency reads/writes, often placed in front of durable transactional databases.

Latency profile

Sub-ms reads/writesIn-memory accessPipeline batching

System design use cases

Cache/session storeRate limitingLeaderboard/real-time counters

Operational trade-offs

RAM costEviction tuningReplication lag on read replicas

Read / Write Path through components

The diagram combines write and read paths with operational notes: how Redis commands are routed, executed, and acknowledged in single-node and cluster topologies.

Read/Write Path Explorer

Interactive walkthrough of how Redis commands move through instance/cluster components.

1
Client Command
SET HSET XADD
2
Routing
slot owner
3
Command Execute
event loop
4
Durability + Replica
AOF/RDB + PSYNC
5
Ack + Visibility
primary state
Write path: command is routed to slot owner, mutates in-memory state, then acknowledged with persistence/replication behavior.

Write path

  1. Application sends write command (`SET`, `HSET`, `XADD`) to Redis endpoint.
  2. In cluster mode, command is routed to hash-slot owner primary; cross-slot operations require key design discipline.
  3. Primary applies mutation in RAM and asynchronously replicates to replicas via PSYNC.
  4. Durability is tuned with RDB/AOF; latency vs safety depends on `appendfsync` and persistence settings.

When to choose Redis

Good fit

  • Hot-data caching and API acceleration with sub-ms requirements.
  • Session storage, rate limiting, distributed counters, and leaderboards.
  • Pub/Sub and Streams for real-time events and lightweight queueing.
  • Workloads where simple access patterns and speed matter more than complex ad-hoc queries.

Avoid when

  • As the only source of truth for critical business data without a well-designed persistence strategy.
  • Complex analytics and arbitrary join-heavy querying over large datasets.
  • Workloads where active data volume significantly exceeds available RAM.
  • Teams not ready to manage eviction policy, replication lag, and backup/recovery operations.

Practice: DDL and DML

Below are practical Redis commands: DDL-like keyspace/config operations and DML data read/write commands.

DDL and DML examples in Redis

Redis has no classic SQL DDL, but DDL-like operations define keyspace, durability, and access policy.

The DDL-like layer in Redis is mostly operational schema: durability settings, ACL boundaries, and structural primitives such as consumer groups.

Configure durability and memory policy

CONFIG SET

Define AOF behavior and eviction strategy under RAM limits.

CONFIG SET appendonly yes
CONFIG SET appendfsync everysec
CONFIG SET maxmemory 4gb
CONFIG SET maxmemory-policy allkeys-lru

Prepare stream topology with consumer group

XGROUP CREATE

Create stream + consumer group as a structural base for event processing.

XGROUP CREATE orders:events order-service 0 MKSTREAM

ACL profile for application user

ACL SETUSER

Restrict application access by namespace and command groups.

ACL SETUSER app on >S3cr3t
~app:*
+@read +@write
-FLUSHALL

Related materials

Related chapters

Enable tracking in Settings

System Design Space

© 2026 Alexander Polomodov