Redis
In-memory data structure server used for caching, queues, counters and coordination, with single-threaded command execution.
What it is
An in-memory data structure server. It holds the dataset in memory, executes commands from a single thread, and offers optional persistence. Since 2024 it is licensed under RSALv2/SSPLv1, with AGPLv3 added in 2025 — the change that prompted the Valkey fork.
Architecture
Single-threaded command execution makes every operation atomic without locks and latency highly predictable. It also means one slow command blocks every client. Additional threads handle I/O and background freeing of large objects, but command execution remains serial.
Best use cases
- Caching, with TTLs and eviction policies designed for it.
- Rate limiting and counters, using atomic increments with expiry.
- Session storage where loss on failover is acceptable.
- Queues and event streams via Streams, which provide consumer groups and acknowledgements.
- Leaderboards and ranked sets via sorted sets.
When not to use it
- As a durable system of record — replication is asynchronous and persistence is configurably lossy.
- For datasets substantially larger than RAM.
- For complex queries: no planner, no joins, no secondary indexes in core Redis.
Data model
Keys mapped to typed values: strings, hashes, lists, sets, sorted sets, streams, bitmaps, HyperLogLogs and geospatial indexes. Small collections use compact encodings that switch to general ones past configurable thresholds.
Consistency and transactions
MULTI/EXEC provides isolation and all-or-nothing execution, with no rollback on runtime
errors. WATCH gives optimistic concurrency. Lua scripts and Functions run atomically.
Scaling model
Vertically — single-thread speed matters more than core count. Read replicas for read scaling. Redis Cluster distributes 16384 hash slots across primaries, at the cost of multi-key operations requiring a shared slot.
Replication
Asynchronous. A failover loses whatever the primary had not shipped. WAIT narrows the window
without eliminating it. Sentinel provides automatic failover for non-clustered deployments.
Backup and recovery
RDB snapshots and the append-only file. Copy the RDB to storage in another failure domain — a
replica is not a backup, since it faithfully replicates a FLUSHALL.
Monitoring
INFO sections (memory, stats, replication, persistence, clients), the slow log, LATENCY
commands, and INFO commandstats. See Redis Monitoring.
Common mistakes
Production checklist
See Redis Production Checklist.