Redis use cases, explained for system design interviews
Almost every system design you draw ends up with a fast store sitting in front of the database, and nine times out of ten that store is Redis. Ask what is Redis used for and the honest answer is "a lot of different things that happen to share one property" — an in-memory data store so fast that it becomes the default answer to "how do we make this read quicker," "where do we keep the session," "how do we count requests per second," and "how do we rank the top players." The interview isn't testing whether you can name Redis; it's testing whether you know which of its use cases fits the problem on the whiteboard, which data structure backs it, and what breaks when you lean on it too hard.
The reason redis use cases are worth drilling as their own topic is that Redis shows up in more system design rounds than almost any other single component, and each use case comes with a different follow-up. Redis caching is the one everyone reaches for, but the interviewer's real questions are about what happens when the cache and the database disagree, what gets evicted when memory fills, and whether you can afford to lose the data in a crash. This guide walks what a strong candidate names out loud: why Redis is fast, the data types that power each use case, the canonical use cases (caching, sessions, rate limiting, leaderboards, locks, pub/sub, queues), and the tradeoffs — persistence, eviction, and the fact that a cache is not a system of record — that the round is really about.
Why Redis comes up in system design interviews
Redis rarely gets its own prompt. It appears inside almost any design — a news feed, a URL shortener, a rate limiter, a payment flow, a gaming leaderboard — the moment the interviewer asks how you make reads fast, hold state between requests, or coordinate across servers. You say "I'll put Redis in front of the database," and the follow-up is the trap: now there are two copies of the truth, and they drift. The whole point of a cache is that it is not the source of truth, so the interview goes straight at the seam — staleness, invalidation, eviction, and what you lose if the Redis node dies. Naming Redis is the easy half; knowing exactly which use case you're invoking and what it costs is where redis system design understanding shows.
The interviewer rarely lets "add a Redis cache" stand on its own. "You put Redis in front of your database as a cache. The cache and the DB disagree — a user sees stale data. Where did that come from, and how do you bound it?" That question — where inconsistency enters and how you put a ceiling on it — is the one a memorised "use Redis for caching" answer can never survive.
The rounds on Zynter are modelled on how the loop runs, not scraped from any candidate's recall. What matters for prep is the shape: you name the use case, and the next sentence attacks a stale read, an evicted key, a lost session, or a single slow command that froze every other request on the box.
What the interviewer is really testing
A Redis answer is read on the same four dimensions as any design decision. Problem solving — did you pick Redis because the access pattern actually fits an in-memory store, and choose the right data structure, or just sprinkle "cache" on everything? Communication — can you say in one sentence why Redis is fast and why a cache is not a system of record? Technical execution — do you handle invalidation, pick an eviction policy, and know RDB versus AOF? Time management — did you spend your words on the tradeoff that matters for this design, not on reciting every Redis command? Reading this guide teaches the concepts; it does not teach you to defend an eviction policy while someone asks what happens when the cache is cold.
Why Redis is fast: in-memory, single-threaded, and rich data types
Start with why Redis is fast, because every use case rides on the same three properties and the interviewer expects you to name them.
- In-memory. Redis keeps the entire dataset in RAM and serves reads and writes from memory, so a lookup is a pointer dereference, not a disk seek — sub-millisecond, often hundreds of thousands of operations per second per node. The flip side, which you must say out loud: your data is bounded by RAM, and RAM is expensive, so Redis is a store for hot data, not everything.
-
Single-threaded event loop. Command execution runs on a single thread through an event loop, so each command is effectively atomic and there are no locks or race conditions between commands. That is a feature — but it is also the sharpest edge: one slow command (a big
KEYS *, a huge sorted-set range) blocks every other client on that node until it finishes. "Single-threaded means one expensive command stalls everyone" is a tell that you actually understand Redis. - Rich data structures. Redis is not just a string key-value store. It ships strings, hashes, lists, sets, sorted sets, streams, and probabilistic types like HyperLogLog — and each use case below is really "pick the data structure whose operations match the problem." The data structures are the reason one system can be a cache, a leaderboard, a queue, and a rate limiter at once.
The sentence that scores: Redis is fast because it's in-memory and served by a single-threaded event loop, which makes each command atomic but means one slow command blocks the node; and its value is the rich data structures — strings, hashes, sorted sets, streams — that let the same store back caching, leaderboards, queues and counters. Naming all three, and the cost of each, frames every use case that follows.
The canonical Redis use cases and the data type behind each
The trick to a strong answer is to pair each use case with the data structure and the command that makes it work. These are the ones worth having automatic:
- Caching (the default). Store the result of an expensive query or computation under a key with a TTL, so repeat reads skip the database. Backed by strings (or hashes for object fields). Patterns: cache-aside (the app checks Redis, misses to the DB, then writes the result back) and read-through (the cache layer fetches on a miss). This is the most common Redis use case by far, and the one with the most follow-ups.
- Session store. Keep user session state (login, cart, preferences) in Redis so any stateless app server can serve any request. Backed by hashes with a TTL that matches the session timeout. Reads are sub-millisecond and the session survives a single app server dying.
-
Rate limiting. Count requests per user per window. The simplest form is
INCRon a key plusEXPIREto reset the window (fixed window); a token bucket or sliding window uses the same atomic counters. Backed by strings as counters — the single-threaded atomicity ofINCRis exactly why this is correct without extra locking. -
Leaderboards / ranking. Keep a live ranking — top players, trending posts, most-viewed — with sorted sets:
ZADDto set a score,ZRANGE/ZREVRANGEto read the top N,ZRANKfor a member's position. All O(log N), which is why Redis is the canonical leaderboard answer. -
Distributed locks. Coordinate exclusive access across servers with
SET key value NX PX <ttl>(the modernSETNX+ expiry): one holder, auto-expiring so a dead holder can't deadlock. For stronger guarantees across nodes there is Redlock — but say its caveat out loud: it's debated, and a single-instance lock is fine for most designs, strict correctness needs fencing tokens. -
Pub/sub and streams (lightweight messaging).
PUBLISH/SUBSCRIBEis fire-and-forget fan-out (no persistence — a subscriber that's offline misses the message); Streams (XADD/XREADGROUP) add an append-only log with consumer groups and acknowledgements for at-least-once delivery. -
Queues. A simple work queue from a list —
LPUSHto enqueue,BRPOPto block-and-pop — or a durable one from a stream with consumer groups. Good for background jobs when you don't need a full broker like Kafka.
The sentence that scores: the use case is really a data-structure choice — strings for caches and counters, hashes for sessions, sorted sets for leaderboards, lists or streams for queues, SET NX for locks — and Redis fits when the access pattern is hot, simple, and benefits from atomic in-memory operations. Pairing each use case with its structure is the signal that you've actually built with Redis, not just read about it.
System Design
HLD · Core concept
Pick the right Redis use case and data type out loud
Caching patterns and persistence: cache-aside, eviction, RDB vs AOF
Because caching is the use case that gets probed hardest, know the patterns and the durability story cold.
- Cache-aside (lazy loading). The app owns the cache: read Redis, on a miss read the database, then write the value back to Redis with a TTL. Simple and the default — but the first read of any key is always a miss, and you must invalidate on write (delete or update the key) or readers see stale data. This is where the stale-data follow-up lives.
- Read-through / write-through. The cache layer sits inline: read-through fetches from the DB on a miss for you; write-through writes to the cache and DB together so they stay in sync, at the cost of write latency. Write-behind buffers writes and flushes later — faster, but you can lose buffered writes.
-
Eviction policies. RAM is finite, so you set
maxmemoryand an eviction policy for when it fills: LRU (evict least-recently-used), LFU (least-frequently-used),volatile-ttl(evict keys nearest expiry), ornoeviction(reject writes). Pickingallkeys-lrufor a pure cache and naming why is a real signal — the wrong policy quietly evicts hot keys. -
Persistence: RDB vs AOF. Redis is in-memory, so a crash loses data unless you persist. RDB takes point-in-time snapshots — compact, fast restart, but you lose everything since the last snapshot. AOF (append-only file) logs every write — far less data loss (down to one second with
everysec), but larger files and slower restart. You can run both. The interview point: a cache usually needs neither — if Redis is a cache, losing it just means a cold start from the database; persistence matters only when Redis holds data that isn't recoverable elsewhere (a session store, a queue).
The sentence that scores: for a cache I'd use cache-aside with a TTL and explicit invalidation on write, allkeys-lru eviction under a maxmemory cap, and no persistence — a cache loss is just a cold start; I'd turn on AOF only when Redis is the source of truth for that data, like sessions or a queue. That connects the pattern, the eviction policy, and the durability decision in one breath.
System Design
HLD · Core concept
Defend a caching pattern and persistence choice out loud
The pitfalls interviewers probe
Redis is not a free "make it fast" button, and naming its sharp edges is what separates a real answer from a buzzword:
- It's a cache, not a system of record (the big one). Redis in front of a database is a copy of hot data, not the truth. Treat it as authoritative and a crash or an eviction silently drops data. State plainly which store owns the truth and how the cache is rebuilt — that single sentence is the biggest tell.
- Staleness and invalidation. The hardest problem in caching is keeping the cache and the database in agreement. Bound it with TTLs (staleness has a ceiling), invalidate on write, and know that cache invalidation is genuinely hard — you can't make it perfect, only bounded.
-
Single-threaded means one slow command blocks all. Because command execution is single-threaded, a
KEYS *on millions of keys, a giantZRANGE, or an un-indexed scan stalls every other client on the node. UseSCANoverKEYS, keep values small, and watch for big-O-expensive commands. -
Memory and eviction surprises. When
maxmemoryis hit, the eviction policy decides what dies — the wrong policy evicts data you needed, andnoevictionturns a full cache into failing writes. Size for the working set and pick the policy deliberately.
The point to state plainly: Redis buys you speed, but it is a cache first — so you name the source of truth, bound staleness with TTLs and invalidation, keep commands cheap because one slow one blocks the box, and choose eviction and persistence to match whether the data is recoverable elsewhere.
How to talk about Redis in an interview
The probes from every section rhyme. Master these five and you can defend Redis in any design, not just this checklist.
- "Why Redis here instead of the database?" → It's in-memory and single-threaded, so reads are sub-millisecond and atomic; I'm caching hot data to take read load off the DB, not replacing it. (problem solving)
- "Which data structure, and why?" → Match the structure to the access pattern — strings for caches and counters, hashes for sessions, sorted sets for leaderboards, lists or streams for queues. (technical execution)
- "The cache and DB disagree — where did stale data come from?" → Cache-aside plus a TTL and invalidate-on-write; staleness is bounded by the TTL, and cache invalidation is the hard part you design for, not avoid. (communication)
-
"Redis fills up / the node crashes — now what?" →
maxmemorywithallkeys-lruso hot keys survive; a cache loss is a cold start from the DB, and I add AOF only when Redis owns the data (sessions, a queue). (technical execution) -
"What's the risk of a single slow command?" → Single-threaded execution means one expensive command (
KEYS *, a huge range) blocks every client; useSCAN, keep values small, avoid O(N) commands on big keys. (problem solving)
Each maps to a debrief dimension. Reading them teaches the answers; it does not teach you to deliver them while someone asks what happens when the cache is cold — that only comes from saying them out loud.
How to prepare: a short plan
You don't need a new topic for every design. You need the Redis vocabulary automatic, so when a design needs speed you reach for the right use case and data structure without thinking.
- Day 1: Learn why Redis is fast — in-memory, single-threaded event loop, rich data structures — until you can name the cost of each from memory.
- Day 2: Drill the use cases paired with their data structures (cache→string, session→hash, rate limit→INCR, leaderboard→sorted set, lock→SET NX, queue→list/stream) and the caching patterns — cache-aside, invalidation, eviction, RDB vs AOF.
- Day 3: Place Redis inside a real design (a feed, a rate limiter, a leaderboard): pick the use case, name the data structure, choose eviction and persistence, and say which store owns the truth. Then do it out loud, timed, with someone asking what happens when the cache is cold.
This explainer feeds the broader Top 25 system design interview questions — Redis shows up in caching, rate limiting, feeds and leaderboards, so getting the use cases automatic pays off across the whole list.
Frequently asked questions
What is Redis used for?
Redis is an in-memory data store used anywhere a system needs fast access to hot data, and because it ships several data structures it covers many use cases at once. The most common is caching — storing the result of an expensive query or computation under a key with a TTL so repeat reads skip the database. Beyond that it's used as a session store (hashes keyed by session id), a rate limiter (atomic INCR counters with EXPIRE), a leaderboard or ranking (sorted sets with ZADD/ZRANGE), a distributed lock (SET NX with an expiry), and lightweight messaging or queues (pub/sub, streams, or lists). The common thread is that all of these benefit from sub-millisecond, atomic, in-memory operations — Redis is the fast layer, not the system of record.
Why is Redis so fast?
Three reasons, and a strong answer names all three. First, Redis keeps data in RAM and serves reads and writes from memory, so there's no disk seek — lookups are sub-millisecond and a single node handles hundreds of thousands of operations per second. Second, command execution runs on a single thread through an event loop, which makes each command atomic with no locking overhead between commands. Third, its rich data structures (strings, hashes, lists, sets, sorted sets, streams) let the engine do work in optimised native operations rather than round-tripping data to the application. The tradeoff is that the dataset is bounded by RAM, and the single thread means one slow command blocks every other client on the node.
Is Redis a good database, or just a cache?
Redis can be used as a primary database, but in most system design answers you treat it as a cache or a specialised store, not the system of record. As a cache it holds a copy of hot data in front of a durable database, so a crash or an eviction just means rebuilding from the source — that's usually fine. If you want Redis to own data that isn't recoverable elsewhere (sessions, a queue, a leaderboard), you turn on persistence (RDB snapshots or the AOF append-only log) and accept the durability and memory tradeoffs. The interview-safe framing is: name which store owns the truth, and use Redis for speed on top of it unless the data is genuinely disposable.
What is the difference between RDB and AOF persistence in Redis?
They are the two ways Redis persists its in-memory data to disk so a crash doesn't lose everything. RDB takes point-in-time snapshots of the dataset at intervals — the files are compact and restart is fast, but you lose any writes made since the last snapshot. AOF (append-only file) logs every write operation to disk, typically flushed every second, so you lose at most about a second of data — at the cost of larger files and slower restart. You can run both together for a balance of fast restart and low data loss. For a pure cache you often need neither, because losing the cache just forces a cold start from the database.
How do I practise a system design interview out loud?
Reading about Redis use cases is not the same as defending a caching choice while an interviewer asks where stale data came from. On Zynter, the HLD track runs live voice rounds modelled on how real system design loops run — you talk through a design (a feed, a rate limiter, a leaderboard) on a shared canvas, and a voice interviewer follows up one question at a time ("why Redis here?", "the cache and DB disagree — where from?", "the node crashes — now what?"), then gives you a debrief on problem solving, communication, technical execution and time management. The score is a practice signal, not a hiring decision.
Practise it on Zynter
You can say "add a Redis cache." The round is won on invalidation, eviction, and which store owns the truth.
Pick an HLD system design round that needs a fast layer — a feed, a rate limiter, a leaderboard — put Redis on the canvas, and defend it out loud to a voice interviewer that keeps asking "why Redis here?" and "the cache and the DB disagree — where did that come from?" — then read the debrief. Zynter.ai is on-demand mock interviews modelled on real company loops, with 150+ rounds across 20 companies including the HLD system design track (Sep 2026).
Practise an HLD system design round →
Browse all interview tracks




Top comments (0)