32 Redis interview questions with detailed answers, sorted from basic to advanced. Free to practice, with progress saved automatically.
Redis is an in-memory key-value store used for caching, counters, lightweight queues and session data. The questions cover its data structures, caching strategies such as cache-aside and write-through, cache stampede, hot keys, persistence and durability, Sentinel, Cluster and slot sharding, rate limiting, security, and when Redis is the wrong tool.
Redis is an in-memory key-value store, commonly used for caching, sessions, counters, rate limiting and simple queues. Beyond strings it has built-in data structures such as lists, hashes, sets and sorted sets. Why it is fast: - Data lives in RAM. Reads and writes never…
Redis is a key-value store, but values come in several types, and each type comes with its own commands, so picking the right type saves you from doing the work in application code. The five core types: - String: the most basic type. Used for…
RDB (snapshot) is a point-in-time image of the whole dataset, saved as an .rdb file. AOF (Append-Only File) is a log of every write command; on restart, Redis replays those commands to rebuild the data. The save line reads: snapshot if at least 1 change…
Redis Pub/Sub lets a publisher push a message to a channel, and every subscriber currently listening on it receives the message immediately: It is fire-and-forget by nature: messages are never stored. If no subscriber is online at publish time the message is gone, and a…
A transaction in Redis is a group of commands wrapped between MULTI and EXEC. After MULTI, the server only queues commands (replying QUEUED); at EXEC it runs the whole group back to back, with no other client's command in between. A pipeline is just a…
These are two different mechanisms that people often mix up: expiration removes a key because its TTL ran out, while eviction removes keys because Redis hit the maxmemory limit, even keys that have not expired. Expiration. Set a TTL with EXPIRE key 60, PEXPIRE (ms)…
Memcached is a pure cache: exactly one data type (string), multi-threaded, simple to operate. Redis brings a whole toolbox of data types (String, Hash, List, Set, Sorted Set, Stream, HyperLogLog, Geospatial) plus persistence, pub/sub, transactions, Lua scripting and native clustering. Choose Memcached when: you only…
Redis is a multi-purpose in-memory store widely used for caching, sessions, rate limiting, leaderboards, and distributed locking in most modern production stacks. Most common production use cases for Redis: - Caching: storing database query results, API responses, and rendered HTML to reduce latency and database…
The common convention is to join parts with colons in the order object type → id → attribute, e.g. user:1001:profile, order:5521:status. Redis does not interpret :, it is only a convention, but it lets tools such as RedisInsight show keys as a tree and makes…
HyperLogLog (HLL) is a probabilistic data structure for counting distinct elements (cardinality). It does not store the elements themselves, only a summary of at most 12KB; in exchange the result is an estimate with a 0.81% standard error. PFADD records elements, PFCOUNT returns the estimate,…
A Redis Bitmap is not a separate data type; it is a String manipulated bit by bit. A String can be up to 512MB, about 4.29 billion bits, and each bit is addressed by an offset. Bitmaps fit best when you need a yes/no answer…
A Sorted Set (ZSET) is a set of unique members, each tagged with a numeric score. Redis always keeps them ordered by score, so inserts and updates cost O(log N) and reading by rank is cheap. Both problems rely on this property. Leaderboard: the member…
There are two ways to store an object such as user:1: - String: serialize the whole object as JSON into one key. Reading the whole object takes a single GET. - Hash: each attribute is a field inside the key, so fields can be read…
Cache-Aside (lazy loading) means the application manages the cache itself: read the cache first, and only on a miss read the DB and write the result into the cache. On a write, the application updates the DB and then deletes (or updates) the key in…
Sessions have three requirements: very fast reads (every authenticated request has to look up the session), automatic expiry (log out after too long idle) and no need for long-term storage. Redis covers all three out of the box: data lives in RAM, GET/SET by key…
Redis Sentinel is a set of separate monitoring processes running alongside a Redis setup of one master and its replicas. When the master dies, Sentinel promotes a replica to be the new master and tells clients the new address, with no human involved. Sentinel does…
When data reaches the maxmemory limit, the eviction policy decides which key Redis deletes to make room for a new write. You set it with maxmemory-policy, and it combines two choices: by what criterion to delete, and from which set of keys. Deletion criterion: -…
Redis is powerful because it runs in-memory and executes commands single-threaded — those same traits are its limits: - Memory-bound: the whole (hot) dataset must fit in RAM, which is far more expensive than disk. A poor fit as a primary store for data larger…
Redis is designed by default to run on a trusted internal network, so the protections below must be configured yourself once it is exposed beyond that. - AUTH (requirepass): set a password; clients must AUTH <password before issuing commands. A basic mechanism, one password for…
Redis does persist to disk, but its durability is weaker than an RDBMS and you must understand it before relying on it. Two mechanisms: - RDB: periodic point-in-time snapshots of the dataset. Small files, fast restart, but loses writes made after the last snapshot (often…
A hot key is one key receiving disproportionate traffic — a global config entry, a flash-sale product, the counter of a viral post. In Redis Cluster a key maps to a hash slot, and each slot lives on exactly one node, so all traffic for…