dbstack

← All tools

Redis

An in-memory data structure store used as a cache, queue, and pub/sub broker.

in-memory key-value cache pub-sub

What it is

Redis is an in-memory data structure store. It speaks a simple text protocol (RESP) and supports strings, lists, sets, sorted sets, hashes, streams, geospatial indices, HyperLogLogs, bitmaps, and pub/sub channels. It started in 2009 as a side project by Salvatore Sanfilippo (“antirez”) and is now the default answer to “I need a cache” in most backend stacks.

Redis has been through two license changes in 2024–2025. In March 2024, the license moved from BSD to a dual SSPL/RSAL — neither OSI-approved as open source. The shift prompted the Linux Foundation to fork Redis as Valkey, with backing from AWS, Google, and Oracle. In May 2025, Redis Inc. released Redis 8 under a triple-license offering of AGPLv3, SSPL, or RSAL, which restored some form of open-source availability but still doesn’t qualify as a permissive license. Most cloud providers now ship Valkey instead.

Why people use it

  • Latency. Sub-millisecond reads on modern hardware. Memory access is faster than disk by orders of magnitude.
  • Data structures, not just KV. Sorted sets enable leaderboards and time series. Lists work as queues. Streams provide Kafka-light semantics. Hashes store compact objects. Each structure has O(log n) or O(1) operations for most common patterns.
  • Pub/sub. Channels and keyspace notifications let services react to data changes without polling.
  • Replication and HA. Async primary-replica replication, with Sentinel for automatic failover and Cluster mode for sharding.
  • Ubiquitous. Every major language has a polished client library. Documentation, tutorials, and operational knowledge are abundant.

When to use Redis

  • Caching. The single most common use case. Cache database query results, rendered page fragments, API responses.
  • Session storage. Web sessions in a fast, expireable store.
  • Rate limiting. Token buckets, sliding windows. Redis primitives (INCR, EXPIRE) make implementation trivial.
  • Leaderboards and counters. Sorted sets are purpose-built for ranked data.
  • Lightweight queues. Lists or Streams as queues for background jobs.
  • Distributed locks. With care — Redlock has known limitations.

When not to use Redis

  • Primary durable store. Redis is memory-first; persistence is best-effort by default. AOF helps but is async. Don’t treat it as your system of record.
  • Datasets that don’t fit in RAM. Redis-on-disk (with paging via Redis Enterprise) exists, but vanilla Redis assumes data fits in memory.
  • Complex queries. It’s a KV store with structures, not a query engine. Use Postgres or ClickHouse.
  • Cross-key ACID transactions. MULTI/EXEC provides batch atomicity but not full transactional semantics.
  • Use cases that need a permissive license. Consider Valkey or DragonflyDB.

Notable trade-offs

  • License turmoil. 2024 license change disrupted the ecosystem and pushed most cloud providers to Valkey. Redis 8’s return to AGPLv3 doesn’t restore the original permissive terms. Pin to a specific version and license you’ve reviewed.
  • Memory cost. RAM is more expensive than disk. Plan for ~2× memory overhead (Redis itself, fragmentation, replication buffers).
  • Single-threaded core. Redis 7 added multi-threaded I/O, but command execution is still single-threaded. CPU-bound commands (e.g., big SORT) block the entire server.
  • Cluster mode caveats. Multi-key commands must hit the same hash slot. Lua scripts, transactions, and pub/sub have constraints across shards.
  • Persistence trade-offs. RDB snapshots are fast but lose recent writes between snapshots. AOF is durable but slower and grows large. The defaults may not match your needs.

Ecosystem

  • Valkey. BSD-licensed Redis fork led by the Linux Foundation, backed by AWS, Google, Oracle. Now the default Redis-compatible binary on most cloud providers (AWS ElastiCache for Valkey, Azure Cache for Valkey).
  • KeyDB. Multi-threaded Redis fork acquired by Snap; less actively developed since the acquisition.
  • DragonflyDB. Redis-compatible alternative with much higher per-node throughput; not a fork but a clean-room reimplementation.
  • Redis Stack. Redis bundled with modules: RedisJSON, RediSearch, RedisGraph (now deprecated), RedisBloom, RedisTimeSeries.
  • Cloud. Redis Cloud (official), AWS ElastiCache (Redis or Valkey), Google Cloud Memorystore (Redis or Valkey), Upstash (serverless Redis), Aiven.