Redis
Redis is an in-memory data structure server: strings, hashes, lists, sets, sorted sets, streams and more, read and written over one TCP port in microseconds. It fits caches, rate limiters, session stores, leaderboards and job-queue brokers, and it does not fit as a system of record. Licensing changed twice: BSD-3 through 7.2, RSALv2 or SSPLv1 for 7.4, and RSALv2, SSPLv1 or AGPLv3 from 8.0. Valkey is the BSD-licensed fork for teams that need a permissive licence.
Redis is an in-memory data structure server: strings, hashes, lists, sets, sorted sets, streams, bitmaps and HyperLogLogs, accessed over a network in O(1) or O(log n) per operation. It solves the problem of data that is short-lived, read from many processes and too hot to fetch from disk each time: cache entries, counters, sessions, queues. The official docs at redis.io/docs own the command reference.
What it is
An in-memory key-value-and-more store with optional persistence. Command execution is single-threaded per instance (Redis 8 added a new I/O threading implementation, set with io-threads, for network throughput on multi-core hosts). Single binary, single port (6379), single config file. Sub-millisecond reads and writes when the dataset fits in RAM. Replication, Sentinel-based failover and Redis Cluster for sharding are built in.
Release lines. The current line is 8.x: 8.10.2 shipped 2026-09-17, with patch releases on the 8.8, 8.6, 8.4 and 8.2 lines the same day. The 7.4 line still gets security fixes: 7.4.11 shipped 2026-08-17. Redis plans one major release a year and a minor about six months later; the latest stable release is fully supported, and the previous minor and the previous major get critical and security fixes only (release policy).
Licence, which changed more than once (redis.io licences):
| Version | Licence | OSI open source |
|---|---|---|
| ≤ 7.2 | BSD-3-Clause | Yes |
| 7.4.x ("Redis Community Edition") | RSALv2 or SSPLv1, user's choice | No |
| ≥ 8.0.0 ("Redis Open Source") | RSALv2, SSPLv1 or AGPLv3, user's choice | Yes, under the AGPLv3 option |
The March 2024 switch to RSALv2/SSPLv1 prompted forks. Valkey, a Linux Foundation project under BSD-3, forked from 7.2.4 and is on its own 9.x line now. Redis 8.0 (GA 2025-05-02) added AGPLv3 as a third option, renamed Community Edition to Redis Open Source, and folded the former Redis Stack modules into the core: the Redis Query Engine, JSON, time series, five probabilistic structures (Bloom, Cuckoo, Count-min sketch, Top-k, t-digest) and vector sets (beta). The wire protocol (RESP) stays stable across Redis, Valkey, KeyDB and Dragonfly, so clients work against all of them.
Distribution: the official redis Docker image (Alpine and Debian), APT, RPM, snap and Homebrew packages, plus managed offerings on every cloud (ElastiCache, Memorystore, Azure Managed Redis, Upstash).
How it works
A client opens a TCP connection and sends commands in RESP. The server keeps the whole dataset in memory, runs each command to completion on one thread, and replies. Because no two commands run at once, every single command is atomic, and MULTI/EXEC or a Lua script makes a group of commands atomic too. Persistence runs beside the event loop: RDB forks a child process that writes a snapshot, and AOF appends each write to a log on a configurable fsync policy.
Two access patterns cover most real use. In cache-aside, the application asks Redis first, falls back to the database on a miss, and writes the result back with a TTL. In a broker role, a producer pushes job messages onto a list and workers pop them; Celery's Redis transport (Kombu) keeps popped-but-unacknowledged messages in a separate structure so it can redeliver them after a crash.
Step 1 of 4. The app sends GET for a key such as a computed dashboard. On a hit Redis returns the value in well under a millisecond and the path ends.
Two separate instances: one for the application cache, one used only as the Airflow Celery broker.
The cache path tolerates total loss of Redis: the app falls back to Postgres and refills the cache. The broker path is less forgiving. Queued messages that have not reached a worker exist only in Redis, so a broker restart without persistence drops them, and Airflow has to notice the lost tasks and reschedule them.
When to use it
Reach for it when:
- You need a cache in front of slow data: query results, computed aggregates, API responses, rendered HTML.
- You need a rate limiter:
INCR+EXPIREon a key per IP or user gives a fixed-window limiter in two commands. - You need a session store: stateless JWTs avoid it; sessions in Redis give stateful sessions with revocation.
- The data shape is sets, sorted sets or streams: "is this user in the X cohort", "top traders by P&L this week", "stream of recent events".
- You need a job-queue broker for Celery, Sidekiq, BullMQ or RQ, or a simple queue with Redis Streams and consumer groups.
- You need distributed locks:
SET key value NX EX 30for a single-instance lock; Redlock only where its assumptions hold.
Skip it when:
- The data is your source of truth. Redis can lose recent writes on crash unless AOF is configured with care, and even then treat it as rebuildable.
- The dataset does not fit in RAM. RAM cost scales with state.
- You need ad hoc queries. Core Redis has no
WHERE balance > 100; model the access pattern in the data structure, use the Redis 8 Query Engine, or pick a different store. - You need multi-key transactions with isolation.
MULTI/EXECgives atomic execution, not rollback or isolation levels.
At a glance
Core data structures
- String: bytes, with
GET,SET,INCR,EXPIRE. The workhorse. - Hash: field/value map per key. Object storage without serializing the whole thing. Redis 8 added
HGETEX,HSETEXandHGETDELfor per-field expiry and read-and-delete. - List:
LPUSH/BRPOPgive a blocking queue. Celery's Redis transport uses lists. - Set: unordered unique members. Membership tests in O(1).
- Sorted set (ZSET): members with scores. Leaderboards, time-windowed indexes, priority queues.
- Stream: append-only log with consumer groups, acks and pending lists.
- Bitmap: bit-level operations on strings. Daily active users in a few KB.
- HyperLogLog: approximate cardinality in 12 KB regardless of input size.
Persistence
- RDB: periodic point-in-time snapshots, on by default when no
saveline is configured. Fast restart, compact, loses writes since the last snapshot. - AOF: append-only log of every write, off by default. Durable, larger, with
appendfsync always | everysec | no. - Both at once: RDB for fast restart, AOF for durability. Common for session stores and brokers.
Eviction
With maxmemory set, Redis evicts keys to stay under the limit (eviction docs). allkeys-lru suits a general cache; volatile-ttl suits a cache where the app marks short-lived keys; noeviction fails writes instead. Redis 8.6 added allkeys-lrm and volatile-lrm, which evict the least recently modified keys. maxmemory defaults to 0 (no limit) on 64-bit builds, so the cap is a deliberate choice.
Key facts
| Aspect | Value |
|---|---|
| Default port | 6379 (TCP) |
| Current line | 8.10.x; 7.4.x still gets security fixes |
| Licence | RSALv2 / SSPLv1 (7.4); RSALv2 / SSPLv1 / AGPLv3 (8.x) |
| Threading | One command thread per instance; optional I/O threads |
| HA options | Replicas + Sentinel, or Redis Cluster (16,384 hash slots) |
| Memory default | maxmemory 0 (unbounded) on 64-bit |
Redis compared with its closest rivals
| Aspect | Redis | Valkey | Memcached |
|---|---|---|---|
| Licence | RSALv2 / SSPLv1 / AGPLv3 (8.x) | BSD-3 | BSD-3 |
| Data structures | Full set plus JSON, search, time series | Full Redis 7.2 set plus its own additions | Strings only |
| Persistence | RDB + AOF | RDB + AOF | None |
| Client compatibility | RESP | RESP, drop-in for Redis clients | Memcached protocol |
| Best fit | Teams fine with AGPL or RSAL who want the Redis 8 modules | Self-hosting with a permissive licence | A plain shared cache |
How to integrate
A minimal standalone Redis on Kubernetes, sized as a cache, with the config in a ConfigMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-config
data:
redis.conf: |
maxmemory 256mb
maxmemory-policy allkeys-lru
appendonly no
save "" # pure cache: no RDB snapshots
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
spec:
replicas: 1
selector:
matchLabels: { app: redis }
template:
metadata:
labels: { app: redis }
spec:
containers:
- name: redis
image: redis:7.4.11
args: ["redis-server", "/etc/redis/redis.conf"]
ports: [{ containerPort: 6379 }]
resources:
limits: { memory: 384Mi } # above maxmemory, leaves room for buffers
volumeMounts:
- { name: config, mountPath: /etc/redis }
volumes:
- name: config
configMap: { name: redis-config }
For a broker, flip the persistence and eviction settings so queued jobs survive a restart and are never evicted:
maxmemory 512mb
maxmemory-policy noeviction
appendonly yes
appendfsync everysec
Pointing Celery (and Airflow's CeleryExecutor) at it:
# airflow.cfg [celery]
broker_url = redis://airflow-redis:6379/0
Client defaults: redis-py (sync) or redis.asyncio in Python, ioredis or node-redis in Node. Most clients pool connections. Rules that hold everywhere:
- Set
maxmemoryand a policy. An uncapped Redis grows until the container is OOM-killed. - TTL cache keys.
SET key value EX 300. A cache without TTLs is a memory leak. - Use Lua or
MULTIfor check-then-write. Rate limits and locks need atomicity. - Separate instances by role. The eviction docs recommend separate instances over mixing cache keys and persistent keys in one.
In the GL stack
Redis runs on the production cluster, in the shared stack namespace beside Postgres, Neo4j, MinIO and Keycloak. It is Redis 7.4.11. There are two instances with two jobs:
- App cache and queues. The product APIs use it for caching and for queue work. It is not a system of record: every value in it can be rebuilt from Postgres or recomputed, so losing it costs latency, not data.
- Airflow's Celery broker. The shared Airflow runs the CeleryExecutor, and a separate Redis carries its task messages from the scheduler to the workers.
Both instances run with the default noeviction policy and no maxmemory cap. That is the setting a Celery broker needs, because Celery breaks when Kombu's binding keys disappear. For the app cache it means memory grows until keys expire or are deleted, so a memory cap with an LRU policy on that instance is the next setting to add. Keeping them as two instances means a busy cache cannot fill the broker's memory and stall pipeline runs.
Gotchas
- It is in-memory. Failover, OOM kills and restarts without AOF lose recent writes. Treat the cache contract as the default and reason carefully about anything stronger.
- One command thread. A slow Lua script or
KEYS *against a large keyspace blocks every other client. UseSCANfor iteration in production. - Celery redelivery. The Redis transport redelivers any task not acknowledged within
visibility_timeout, one hour by default. Tasks with ETAs or countdowns longer than that can run more than once (Celery Redis docs). - Evicted broker keys. If Redis evicts
_kombu.binding.*keys, Celery raisesInconsistencyError. Celery's docs ask formaxmemorywithnoevictionorallkeys-lruon a broker instance. - Memory headroom. Replication and AOF buffers are not counted against
maxmemory. Set the container limit abovemaxmemory, or the kernel kills Redis before eviction starts. - Cluster changes semantics. Multi-key operations need keys in the same hash slot. Use
{tag}key names if sharding is likely later. - The 7.4 licence. 7.4 is RSALv2/SSPLv1 only, with no OSI option. Upgrading to 8.x adds AGPLv3; moving to Valkey gives BSD-3.
Risks
- Licence. Two changes in two years. RSALv2 bars offering Redis as a managed service, and SSPL and AGPL carry network-use obligations. Self-hosting for internal use is fine under all three; redistribution or a hosted offering needs legal review, or Valkey.
- Memory cost. RAM is expensive; an unbounded dataset can become the largest line item. Cap it and TTL aggressively.
- Operational complexity at scale. Sentinel and Cluster work, but have sharp edges. Managed offerings earn their cost once Redis matters to uptime.
- Wrong-tool risk. Redis is fast enough to tempt use as a real database. Data that matters belongs in a durable store.
- Security exposure. Out of the box Redis has no password, and an instance reachable from the internet is a known attack target. Bind to private networks, enable ACLs, and keep the patch line current: 7.4.11 and the September 8.x releases carried security fixes.
Alternatives
- Valkey: the Linux Foundation fork, BSD-3, same protocol and clients. The default when the licence matters for a fresh self-hosted deployment.
- Memcached: pick it for a pure cache with no data structures, persistence or pub/sub. Simpler and narrower.
- Dragonfly / KeyDB: pick them for multi-threaded throughput on a single instance. Drop-in protocol, smaller ecosystem.
- Postgres
LISTEN/NOTIFYandSKIP LOCKEDqueues: pick them when Postgres is already there and throughput is modest. One fewer moving part, less raw speed.
Related
- Postgres: the system of record behind every cached value.
- Airflow: the scheduler whose Celery workers take tasks from Redis.
- CloudNativePG: the operator that runs the Postgres clusters beside it.
- Neo4j and MinIO: the other stateful services in the data layer.
- Data layer overview
- Redis docs, Redis licences, Redis releases on GitHub, Valkey
