What Is Redis?
Redis (Remote Dictionary Server) is an in-memory data store used as a distributed cache, message broker, and real-time vector database. Unlike disk-first relational engines or plain string caches such as Memcached, Redis keeps its dataset in RAM and offers native data structures with atomic operations executed on the server.
Because applications work with hashes, sorted sets, streams, and vectors in memory without serializing whole objects over the network, Redis removes the overhead that slows traditional caching tiers. Teams run it next to relational databases to absorb read spikes, coordinate distributed locks, manage sessions, and index embeddings for AI workloads.
Search, JSON, and time-series features used to be separate modules. Redis 8 includes them in the standard distribution and adds the OSI-approved AGPLv3 as a license option alongside the source-available licenses.
Architecture and commands are documented in the official Redis documentation.
How Redis Works
Redis reaches sub-millisecond latency by keeping the active dataset in RAM and executing commands on a single-threaded event loop with multiplexed I/O. Network reads and background disk writes can use helper threads, but commands run one at a time, which removes lock contention and race conditions. Pipelining and Lua scripts batch several operations into one round trip.
Its data structures go well beyond key-value pairs: strings with atomic counters, hashes for object fields, lists and streams for queues and consumer groups, sets and sorted sets for unique collections and leaderboards, probabilistic types such as HyperLogLog and Bloom filters, and JSON documents and vector indexes.
For persistence, RDB writes point-in-time snapshots from a forked child process, while AOF logs every write command and syncs it to disk on each write, every second, or when the OS decides. Most production setups use both, as compared in the table below.
To scale beyond one server, Redis Cluster splits the keyspace into 16,384 hash slots. Clients hash each key with CRC16 and send the command straight to the shard that owns the slot. Hash tags in curly braces keep related keys on the same shard for multi-key operations.
| Persistence option | How it works | Best for |
|---|---|---|
| RDB snapshots | A forked child process writes a compact binary snapshot at intervals. | Fast restarts and offsite backups. |
| AOF log | Every write command is appended to a log and replayed on restart. | Durability down to about one second. |
| RDB plus AOF | Both enabled together. | Most production systems. |
| No persistence | Data lives only in memory. | Pure caches that can be rebuilt. |
Redis is the right tool when the bottleneck is network round trips or contention on the main database: hot reference data, rate limiters, and session tokens move from disk queries to sub-millisecond memory lookups. Production problems usually come from memory exhaustion, very large keys that block the event loop, and a new connection per request in autoscaling environments. We set an explicit maxmemory policy from day one, enforce TTLs, and use connection pooling.
In-memory data store, cache, and message broker
Strings, hashes, lists, streams, sets, JSON, vectors
RDB snapshots and AOF log
AGPLv3, RSALv2, or SSPLv1 (Redis 8)
Years in business
Senior engineers
Projects delivered
What Redis Is Used For
Redis is used for far more than caching: sessions, rate limiting, leaderboards, job queues, and AI vector search, all offloading high-frequency state from relational databases.
Caching and Sessions
Applications cache expensive SQL joins, rendered fragments, and API responses with automatic expiry, and store sessions and cart contents in shared hashes so load balancers need no sticky sessions and deployments never log users out.
Rate Limiting and Distributed Locks
Sorted sets, atomic counters, and Lua scripts implement token-bucket and sliding-window rate limiters in under a millisecond, while lock patterns keep cron jobs and payment tasks from running twice.
Leaderboards and Job Queues
Sorted sets rank millions of entries in real time and HyperLogLogs count unique visitors in little memory. Sidekiq, BullMQ, and Celery use lists and streams to dispatch background jobs and retries.
Vector Search and Semantic Caching
Redis vector search lets AI apps index embeddings in memory with HNSW or FLAT and combine similarity queries with metadata filters, and cache previous LLM answers so similar questions skip repeated generation.
Redis vs Memcached and Valkey
Comparing Redis vs Memcached, Redis wins on data structures, persistence, and replication, while Memcached stays a simple multi-threaded string cache. Valkey is the BSD-licensed community fork of Redis. Redis and PostgreSQL usually work together rather than replace each other.
| Criterion | |||
|---|---|---|---|
| Architecture | In-memory data structure store with optional persistence. | Pure in-memory volatile key-value cache. | In-memory data structure store forked from Redis. |
| Data structures | Strings, hashes, lists, sets, sorted sets, streams, JSON, vectors. | Strings only. | Core structures plus JSON, Bloom filters, and search through modules. |
| Threading | Single-threaded execution with multi-threaded network I/O. | Multi-threaded with a slab allocator. | Single-threaded execution with expanded multi-threaded I/O. |
| Persistence | RDB snapshots and AOF. | None; data is lost on restart. | RDB snapshots and AOF. |
| Scaling | Native cluster with 16,384 hash slots and failover. | Client-side hashing across independent nodes. | Native cluster with 16,384 hash slots. |
| License | AGPLv3, RSALv2, or SSPLv1. | BSD 3-Clause. | BSD 3-Clause. |
When to Choose Redis
Choose Redis when the system needs sub-millisecond access to shared state, atomic operations on collections, pub/sub or stream processing, and in-memory vector search with official vendor support. Memcached only makes sense for flat string caching across many cores, and PostgreSQL with pgvector keeps embeddings transactional at lower cost per gigabyte when latency is less critical.
When Redis Is Not the Right Fit
Redis is not the right fit for multi-terabyte datasets of cold records, where RAM becomes too expensive, or for workloads that need multi-table SQL joins and strict ACID guarantees with no data-loss window on failover. If governance forbids AGPLv3 and source-available licenses, Valkey under the BSD license is the usual alternative with a compatible protocol.
How We Approach Redis Projects
We design Redis deployments around predictable memory ceilings, efficient connection pooling, and clear boundaries between disposable cache data and durable state.
Separate Caches from Durable State
Look-aside caches run with allkeys-lru or volatile-lfu so traffic spikes evict cold keys instead of crashing. Locks, sessions, and job queues run on separate instances with noeviction, AOF set to everysec, and memory alerts.
Client and Key Hygiene
In .NET, Node.js, and Python we use one shared multiplexed connection per process, sensible timeouts, and pipelining or Lua scripts to collapse chatty lookups. Collections are capped and large hashes split by key prefix, all with TTLs.
Capacity Planning
When sizing Redis Cloud, Azure Managed Redis, or AWS ElastiCache, we account for replication buffers, snapshot copy-on-write memory, and vector index overhead, so clusters survive peak writes without swapping.
Sound like the right partner?
Frequently Asked Questions
Direct answers to common questions about Redis licensing, persistence, capacity, and architectural trade-offs.
Is Redis open source again after the Redis 8 license change?
Redis 8 added the OSI-approved AGPLv3 as a license option alongside RSALv2 and SSPLv1. Which license fits, and what obligations apply, depends on how you use, modify, and distribute Redis, so confirm the choice with your legal team. Valkey under the BSD license is the usual alternative for teams that need a permissive license.
Can Redis be used as a primary database?
For bounded, state-heavy workloads such as game state, session stores, or feature stores, yes, with AOF persistence and replication. Replication is asynchronous, though, so Redis does not give the same zero-data-loss guarantees as a relational database. For ledgers and critical records, keep PostgreSQL or SQL Server as the system of record and use Redis as the fast tier.
How does Redis persist data with RDB and AOF?
RDB takes point-in-time binary snapshots by forking a child process that writes to disk while the main process keeps serving requests. AOF appends every write command to a log and replays it on restart. Using both gives AOF’s roughly one-second durability with RDB’s fast restarts and compact backups.
How much data can a single Redis instance hold?
A single instance can hold up to about 4.29 billion keys, and one string value can be up to 512 MB. In practice, RAM and the memory needed for snapshot forks are the limits. As our own rule of thumb, we keep shards below roughly 25 to 50 GB and scale out with Redis Cluster.
What is the difference between Redis and Valkey?
Valkey is an open-source fork created under the Linux Foundation after Redis changed its license in 2024, backed by major cloud providers. It is protocol-compatible with Redis 7.2 under the BSD license and focuses on multi-threaded I/O and memory efficiency. Redis 8, from Redis Ltd., includes the query engine, JSON, and vector search in its core build.
When should you choose Memcached over Redis?
When the only need is a volatile, multi-threaded string cache for HTML fragments or serialized objects, with predictable memory and no disk I/O. Memcached scales across many cores on one machine with little fragmentation. If you need persistence, replication, pub/sub, or server-side list and hash operations, choose Redis.