Skip to content

Top 30 Redis Interview Questions and Answers [2026]

October 11, 2026 15 min read
Redis interview guide by Second Talent
TL;DR: Redis interviews in 2026 test data structure choice, caching patterns, safe locks and rate limiters, Streams, persistence and Cluster. The current release is Redis 8.10 (8.10.2, September 17, 2026), licensed under RSALv2, SSPLv1 or AGPLv3 since Redis 8, while the BSD-licensed Valkey fork is at 9.1.

Redis 8.4 added DELEX key IFEQ value, which deletes a key only if it still holds the value you expect. That one command replaces the Lua script every Redis lock tutorial has shipped for a decade to release a lock safely.

Interviewers who know the stack now ask whether a candidate has noticed, along with the license changes that produced Valkey and the new data types built into Redis 8.

Key takeaways
  1. 1Redis 8.0 folded the Query Engine, JSON, time series and five probabilistic structures into the core server, plus a beta vector set type.
  2. 2Redis 8.6 added two eviction policies, allkeys-lrm and volatile-lrm, which evict the least recently modified keys.
  3. 3Valkey 9.0 supports numbered databases in cluster mode, which Redis Cluster still restricts to database 0.
  4. 4Redis 7.2 and earlier remain under the BSD 3-clause license; only 7.4 and later carry the newer licenses.

Core and Data Types

1. Why is Redis fast, and is it really single-threaded?

Redis keeps all data in memory and executes commands on one main thread, so each command runs start to finish with no locks and no context switches between clients.

An event loop over epoll or kqueue multiplexes thousands of connections onto that thread.

It is not single-threaded overall. Background threads free large values (UNLINK, FLUSHALL ASYNC) and fsync the AOF, and with io-threads set, extra threads read requests and write replies while commands still execute one at a time.

Redis 8.0 shipped a new I/O threading implementation, and the 8.4 release notes cite over 30% more throughput for a 90% read caching workload on 4 cores.

The practical consequence is unchanged: one slow command, such as KEYS * on a large database, blocks every client.

2. Which data type fits which job?

TypeTypical use
StringCached values, counters with INCR, flags, bitmaps
HashAn object's fields, such as a session or user profile; fields can expire on their own since 7.4
ListSimple queues and recent-items lists
SetMembership, tags, unique visitors when exact counts are needed
Sorted setLeaderboards, priority queues, sliding-window rate limits
StreamAppend-only event log with consumer groups
HyperLogLogApproximate unique counts in up to 12 KB with 0.81% standard error
JSON, vector setNested documents and similarity search, built in since Redis 8

A strong candidate chooses by the operations needed, not by the shape of the data: a leaderboard is a sorted set because ZREVRANGE and ZRANK are O(log N), not because scores are numbers. See Redis data types.

3. How are sorted sets implemented?

Large sorted sets use two structures together: a hash table from member to score for O(1) score lookups, and a skip list ordered by score for O(log N) inserts, rank queries and range reads.

Small sorted sets use a compact listpack encoding instead, and Redis converts to the skip list once the set grows past a size threshold.

That split explains a common performance surprise: a sorted set's memory per member jumps when it crosses the threshold. OBJECT ENCODING key shows which encoding a key uses.

Redis 8.6 reduced memory for skiplist-encoded sorted sets and hashtable-encoded hashes.

4. How does key expiration work?

Two mechanisms. Passive expiry: when a client touches a key, Redis checks its TTL and deletes it if expired.

Active expiry: a background cycle samples keys with a TTL and deletes the expired ones, repeating while many samples turn out expired. Together they keep memory from filling with dead keys that nobody reads.

Two follow-ups separate levels. An expired key can still occupy memory briefly, so DBSIZE may count it. And SET without KEEPTTL clears an existing TTL, which is how caches accidentally end up with keys that never expire.

Since 7.4, HEXPIRE sets a TTL on individual hash fields.

5. Which eviction policy should a cache use?

For a pure cache, allkeys-lru or allkeys-lfu. The default, noeviction, returns errors on writes once maxmemory is reached, which is right for a data store and wrong for a cache.

  • allkeys-lfu suits skewed traffic where a small set of keys stays popular.
  • volatile-* policies only evict keys with a TTL and behave like noeviction if none have one.
  • allkeys-lrm and volatile-lrm, added in 8.6, evict the least recently modified keys.

LRU and LFU are approximated by sampling a few keys per eviction, not by tracking exact order. See Key eviction.

6. How do you find and fix big keys and hot keys?

A big key is one value large enough that reading, deleting or migrating it blocks the server, such as a hash with millions of fields. redis-cli --bigkeys and --memkeys scan for them, and MEMORY USAGE key measures one.

Fix them by splitting the value across keys and delete them with UNLINK, which frees memory in a background thread.

A hot key is one key receiving a large share of traffic, which in a cluster overloads the single node that owns it. Redis 8.6 added a HOTKEYS command to detect and report them.

Fixes include a short-lived local cache in the application or replicating the value under several keys and reading one at random.

7. Why is KEYS dangerous, and what does SCAN guarantee?

KEYS pattern walks the whole keyspace in one command, blocking every other client for the duration. SCAN returns a cursor and a small batch per call, so the work is spread across many short commands.

Its guarantees are limited: a full iteration returns every key that existed for the whole scan, but it may return a key more than once, and keys added or removed during the scan may or may not appear.

COUNT is a hint about work per call, not a page size. Code that processes SCAN results must therefore tolerate duplicates. See SCAN.

Caching Patterns

8. What is cache-aside, and how does it differ from write-through?

In cache-aside, the application owns both paths: on a read it checks Redis, and on a miss it loads from the database and writes the result to Redis with a TTL. On a write it updates the database and deletes the cached key.

Redis knows nothing about the database.

Five steps of the cache-aside pattern with Redis: GET from Redis and fall through to the database on a miss, SET the loaded value with a jittered TTL, commit writes to the database, then delete the cached key, with the TTL as a safety net for stale values.

Write-through writes to the cache and the database on every update, so reads after a write always hit, at the cost of caching data nobody reads.

Write-behind writes to the cache first and flushes to the database later, which is fast but can lose writes if Redis fails before the flush.

Most web applications use cache-aside because it fails safe: if Redis is down, reads fall through to the database.

9. How do you prevent a cache stampede?

A stampede happens when a popular key expires and hundreds of requests miss at once and all rebuild it, hammering the database. Three defenses, often combined:

  • A rebuild lock: the first request takes SET lock:key token NX PX 5000 and rebuilds; the others serve the stale value or wait briefly.
  • Early refresh: refresh the value in the background before its TTL expires, triggered by a request close to expiry.
  • Jittered TTLs: add a random spread to TTLs so keys written together do not expire together.

10. How do you keep a cache consistent with the database?

Delete the key after the database write commits, and keep a TTL as a safety net.

Deleting is safer than updating the cached value: two concurrent writers updating the cache can finish in the opposite order to their database writes and leave the older value cached indefinitely.

Even delete-after-write has a race: a reader can load the old row, the writer commits and deletes, then the reader writes the stale value back.

Short TTLs bound the damage; a delayed second delete narrows the window; and for strict needs, invalidating from the database's change stream (change data capture) removes the application from the loop.

11. How would you build a rate limiter in Redis?

The simplest is a fixed window: INCR a key named for the user and the current minute, set an expiry on the first increment, and reject once the count passes the limit. It allows bursts of up to twice the limit across a window boundary.

A sliding window stores each request's timestamp in a sorted set, removes entries older than the window with ZREMRANGEBYSCORE, and counts the rest with ZCARD, all inside a Lua script or transaction so the check and the add are atomic.

Redis 8.8 added INCREX, a window counter that combines the increment, bounds and expiry in one command.

12. How do you implement a distributed lock correctly?

Acquire with one atomic command that sets a unique token and an expiry: SET lock:order:42 <token> NX PX 30000. Release only if you still own the lock, by comparing the token and deleting in one step.

Before 8.4 that needed a Lua script; now DELEX does it:

SET lock:order:42 9f1c NX PX 30000
# ... do the work ...
DELEX lock:order:42 IFEQ 9f1c

The hard part is what the lock cannot promise. If the holder pauses (a GC stop, a slow network) past the expiry, a second client acquires the lock and both act.

Redis's own distributed locks page tells readers to implement fencing tokens when correctness matters: an increasing number the protected resource checks and rejects if stale.

A candidate who mentions fencing without prompting has thought about it.

Redlock. The same page describes Redlock, which takes the lock on a majority of independent Redis primaries. It tolerates a node failure, but it does not remove the pause problem, so fencing tokens still apply.

Atomicity and Messaging

13. MULTI/EXEC, Lua scripts or Functions: which gives you atomicity?

All three run their commands without other clients' commands in between, but they differ in what you can do inside.

  • MULTI/EXEC queues commands and runs them together. You cannot read a value and branch on it inside the transaction, and there is no rollback: if one command fails at runtime, the others still apply. WATCH adds optimistic locking: EXEC aborts if a watched key changed.
  • Lua scripts (EVAL) can read, decide and write atomically. A long script blocks the server like any slow command.
  • Functions, added in 7.0, are Lua libraries loaded once and persisted and replicated with the data, so the application does not have to reload scripts after a restart or failover.

14. What is the difference between pipelining and a transaction?

Pipelining is a network optimization: the client sends many commands without waiting for each reply, cutting round trips. It gives no atomicity; other clients' commands can run between yours.

A transaction gives atomicity but by itself does not cut round trips; clients usually pipeline the MULTI, the commands and the EXEC together to get both.

The common mistake is sending 10,000 commands one by one over a network with a 1 ms round trip: that is 10 seconds of waiting, and a pipeline of batches of a few hundred reduces it to a fraction of that. See Pipelining.

15. When do you use Pub/Sub, and when Streams?

Pub/Sub is fire and forget: a message goes to the clients subscribed at that moment and is never stored, so a disconnected subscriber misses it. It suits live notifications where losing a message is acceptable.

In a cluster, sharded Pub/Sub (SPUBLISH, since 7.0) keeps a channel's traffic on the shard that owns it instead of broadcasting to every node.

Pub/Sub
  • Not stored: offline subscribers miss messages
  • Every subscriber gets every message
  • No acknowledgment or replay
Streams
  • Stored as a key, readable from any ID
  • Consumer groups split the work
  • Pending until XACK, so at least once

Streams are an append-only log stored like any other key. Consumers read history from any ID, consumer groups split the work, and each message stays pending until acknowledged.

Use Streams when messages must survive a consumer restart; use Kafka instead when you need long retention on disk and very high volume (see our Kafka interview guide).

16. How do consumer groups handle a consumer that crashes?

When a consumer reads with XREADGROUP, each message enters the group's pending entries list (PEL) under that consumer until it calls XACK. If the consumer crashes, its messages stay pending.

Another consumer finds messages idle longer than a threshold and takes them over with XAUTOCLAIM (since 6.2) or XCLAIM.

Two newer options change the pattern. Redis 8.4 added a CLAIM option to XREADGROUP, so one call returns both idle pending entries and new ones.

Redis 8.8 added XNACK, which lets a consumer explicitly release a message it cannot process instead of letting it sit until it times out. Delivery is at least once in every case, so handlers must be idempotent.

Persistence

17. How do RDB and AOF compare?

RDB writes a compact point-in-time snapshot from a forked child process. It restarts fast and makes good backups, but a crash loses everything since the last snapshot.

AOF logs every write; with the default appendfsync everysec a crash loses about one second of writes. Since 7.0 the AOF is a multi-part set of files: a base file plus incremental files, tracked by a manifest.

Decision flow for Redis persistence: a pure cache that can be rebuilt needs RDB or nothing, minutes of loss acceptable means RDB snapshots, about one second of loss means AOF everysec plus RDB, and data that can never be lost belongs in a relational database.

The shipped redis.conf has appendonly no, so a default install relies on RDB snapshots only. The Redis docs recommend using both when durability matters: AOF for the recent writes, RDB for backups and faster restarts. See Redis persistence.

18. Why can a snapshot cause memory spikes and latency?

RDB saves and AOF rewrites fork the Redis process. The child shares memory pages with the parent copy-on-write, so every page the parent modifies during the save is duplicated.

On a write-heavy instance, memory use can approach double the dataset during a save, and a server sized with no headroom gets killed by the OS.

The fork itself also pauses the main thread while the kernel copies page tables, which grows with the dataset.

Transparent huge pages make both problems worse, because a one-byte write copies a 2 MB page; the Redis docs advise disabling them. Leave memory headroom and watch latest_fork_usec in INFO.

19. Can Redis be the primary database?

It can for data that fits in memory and tolerates its durability model, and many teams run it that way for sessions, counters and queues.

The limits to name: replication is asynchronous, so an acknowledged write can be lost if the primary fails before replicating it; and even with AOF fsync on every write, a failover can promote a replica that lacks recent writes.

WAIT numreplicas timeout blocks until that many replicas acknowledge prior writes, and WAITAOF waits for them to be fsynced, which narrows the window without making Redis a strongly consistent store.

For data that must never be lost, the system of record is usually a relational database with Redis in front.

Replication and Cluster

20. How does Redis replication work?

A replica connects to the primary and requests a partial resync with PSYNC, sending its replication ID and offset.

If the primary's replication backlog still holds everything after that offset, it sends only the missing stream; otherwise it performs a full sync by sending an RDB snapshot and then streaming new writes.

Replication is asynchronous and replicas are read-only by default.

A backlog that is too small (repl-backlog-size) turns every brief network blip into a full resync, which for a large dataset means a fork, a big transfer and a slow replica, so sizing it for your write rate matters.

Redis 8.0 also shipped an improved replication mechanism.

21. When do you use Sentinel, and when Redis Cluster?

Sentinel adds automatic failover to a single primary and its replicas: several Sentinel processes monitor the primary, agree it is down when a quorum of them sees it, promote a replica, and tell clients the new address.

The dataset still has to fit on one node.

Redis Cluster shards the keyspace across several primaries, each with replicas, and handles failover itself.

Choose Sentinel for high availability when one node's memory and CPU are enough; choose Cluster when the data or the write load outgrows one node. Cluster costs you multi-key flexibility (question 22) and database numbers other than 0.

22. How does Redis Cluster route keys, and what are hash tags?

The keyspace is split into 16,384 hash slots. A key's slot is the CRC16 of the key modulo 16384, and each primary owns a range of slots.

A client sent to the wrong node receives a MOVED redirect with the right one, and smart clients cache the slot map to avoid it. ASK redirects appear only while a slot is being migrated.

Multi-key commands such as MGET, SUNION or a MULTI block work only when all keys hash to the same slot. A hash tag forces that: only the part inside braces is hashed, so {user:42}:cart and {user:42}:profile share a slot.

Overusing one tag recreates a hot shard. See the cluster specification.

23. How do you diagnose latency in Redis?

Start with SLOWLOG GET, which records commands whose execution exceeded a threshold (network time excluded). The usual culprits are O(N) commands on big keys: HGETALL on a huge hash, LRANGE 0 -1, SMEMBERS, or a heavy Lua script.

If the slow log is clean, the latency is elsewhere: LATENCY DOCTOR reports events such as fork time and AOF fsync stalls; INFO shows mem_fragmentation_ratio, evictions and blocked clients; and the client side may be exhausting its connection pool. redis-cli --latency measures round-trip time from a client host, separating network from server.

24. How do you secure a Redis deployment?

  • Never expose it to the internet. Bind to private interfaces; protected mode refuses remote connections when no password is set.
  • Use ACLs (since 6.0) to give each application its own user with only the commands and key patterns it needs, and remove FLUSHALL, CONFIG and DEBUG from application users.
  • Enable TLS for traffic that crosses networks. Redis 8.6 added automatic client authentication from TLS certificates, and 8.10 certificate-based authentication between servers.
  • Patch promptly: the 8.2.0 release fixed a HyperLogLog out-of-bounds write (CVE-2025-32023), and Redis ships security patches across several supported lines at once.

What Changed Recently

Mar 20, 2024
Redis announces RSALv2/SSPLv1 dual licensing from 7.4
Mar 28, 2024
Valkey launched at the Linux Foundation from Redis 7.2.4
May 2, 2025
Redis 8.0 GA, with AGPLv3 added as a license option
Oct 21, 2025
Valkey 9.0: atomic slot migration, hash field expiration
Nov 18, 2025
Redis 8.4: DELEX, FT.HYBRID, atomic slot migration
Jul 29, 2026
Redis 8.10: compact hashes, BACKUP command

25. What happened to the Redis license, and what is Valkey?

On March 20, 2024, Redis Inc. announced that from Redis 7.4 the server would be dual-licensed under RSALv2 and SSPLv1 instead of BSD. Those are source-available licenses that restrict offering Redis as a managed service.

Eight days later the Linux Foundation launched Valkey, a fork of Redis 7.2.4 under the BSD 3-clause license.

With Redis 8.0, released May 2, 2025, Redis added AGPLv3, an OSI-approved open source license, as a third option.

For most companies using Redis internally none of this changes anything; it matters to anyone embedding or hosting Redis for others, and to teams choosing between a cloud provider's Valkey service and Redis.

26. What did Redis 8.0 add?

Per the 8.0.0 release notes, the modules that used to ship separately in Redis Stack became part of the server: the Redis Query Engine for search and vector queries, JSON, time series, and five probabilistic structures (Bloom filter, Cuckoo filter, Count-min sketch, Top-k and t-digest).

It also introduced vector sets, in beta, a new type for similarity search designed after sorted sets.

Other changes: the Community Edition was renamed Redis Open Source, a new I/O threading implementation, new hash commands HGETDEL, HGETEX and HSETEX, and more than 30 performance improvements.

The practical interview angle: a team that ran Redis plus RediSearch and RedisJSON modules can now run a single server.

27. Which Redis 8.2 to 8.10 additions change the classic answers?

  • Locks and compare-and-set (8.4): DELEX ... IFEQ and conditional SET options replace the release-lock Lua script.
  • Streams: XREADGROUP ... CLAIM (8.4), idempotent XADD with IDMP for at-most-once producers (8.6), and XNACK (8.8).
  • Rate limiting (8.8): INCREX as a single-command window counter.
  • Operations: CLUSTER MIGRATION for atomic slot migration and CLUSTER SLOT-STATS (8.4), HOTKEYS and LRM eviction (8.6).
  • Memory (8.10): a compact hash encoding that stores field names once for keys sharing a schema.

Each is listed in the Redis GitHub releases. A candidate need not know them all, but one who still writes the Lua release script for a new project on 8.4+ has not kept up.

28. How does Redis handle vector search now?

Two ways. The Query Engine indexes vectors stored in hashes or JSON documents and answers k-nearest-neighbor queries with FT.SEARCH, filtering on other fields in the same query.

Redis 8.2 added the SVS-VAMANA index type with vector compression, and 8.4 added FT.HYBRID, which runs a text query and a vector query and fuses their scores.

Vector sets are the lighter option: a key holding elements with vectors, added with VADD and queried with VSIM, with no separate index to define.

A good answer weighs memory, since vectors held in RAM are the main cost, and says when a dedicated vector database or PostgreSQL with pgvector would be simpler.

29. What did Valkey 9 add, and how far has it diverged from Redis?

The Valkey 9.0 announcement (October 21, 2025) lists atomic slot migration, where a whole slot moves before the source deletes it, so clients stop seeing redirects and retries mid-migration; hash field expiration; and numbered databases in cluster mode.

It also reports clusters of 2,000 nodes serving over 1 billion requests per second. Valkey 9.1 followed on May 19, 2026.

The two now differ in features, not only licenses. Redis 8 has the built-in Query Engine, JSON, time series and vector sets; Valkey ships search and JSON as separate modules.

Commands added on either side after the 2024 fork, such as DELEX, may not exist on the other, so "Redis-compatible" needs checking command by command.

30. Which Redis version should a new project run?

Redis 8.10, the latest line, at 8.10.2 as of September 17, 2026, or the matching Valkey 9.1 on a cloud service that offers it.

Redis maintains several lines at once: on September 17, 2026 it shipped patches for 8.2, 8.4, 8.6, 8.8 and 8.10 together, and in August it also patched 7.2 and 7.4.

What matters more than the minor version is knowing the license you are running under and which commands your code depends on. A candidate should be able to say whether their managed service is Redis or Valkey, and why that choice was made.

Signs of a Strong Answer

  • They name the O(N) command and the big key behind a latency spike, not "Redis is slow".
  • They release locks with a token check and raise fencing tokens for correctness-critical work.
  • They know a cache's eviction policy must be changed from the noeviction default.
  • They leave memory headroom for fork copy-on-write and can explain why.
  • They use hash tags deliberately in Cluster and know the hot-slot risk.
  • They can explain the RSALv2, SSPLv1, AGPLv3 and Valkey situation in two sentences.

Hiring Redis Developers

Second Talent places pre-vetted back-end engineers and Node.js developers from Asia who run Redis in production, screened with questions like these. For budgets, see the cost to hire a backend developer.

Tell us the role and we send a shortlist within 24 hours. Related guides: PostgreSQL and MongoDB.

Get developers who ship with AI agents. Starts at $25/Hour.

Start Hiring $0 cost until you hire