Redis Interview Questions & Answers (2026)
These interviews test your grasp of Redis fundamentals, data structures, persistence mechanisms, clustering, and real‑world usage patterns. Demonstrate clear understanding of command semantics, trade‑offs between memory and durability, and how to design scalable solutions. Show practical experience with pipelining, Lua scripting, and monitoring to convince interviewers you can operate Redis in production.
22 questions · updated Aug 29, 2026
Quick facts
| Typical rounds | Phone screen, technical deep‑dive, system design, and on‑site coding |
| Core topics | Data types, persistence, clustering, performance, security |
| Common tools | redis-cli, RedisInsight, Docker, Kubernetes operator |
| Experience level | 0‑2 years for junior, 2‑5 years for mid, 5+ for senior |
Questions
Beginner
What are the main data structures Redis provides and when would you choose each?
Redis offers strings, lists, sets, sorted sets, hashes, bitmaps, hyperloglogs, and streams. Strings are best for simple key‑value caching or counters. Lists excel at FIFO/LIFO queues. Sets provide unique unordered collections, useful for tagging. Sorted sets add scoring for leaderboards. Hashes store object fields efficiently. Bitmaps enable bit‑level operations like feature flags. Hyperloglogs give approximate distinct counts with minimal memory. Streams support durable message queues with consumer groups. Choosing depends on access patterns, ordering needs, and memory efficiency.
Explain Redis persistence options and their trade‑offs.
Redis supports RDB snapshots and AOF logging. RDB writes periodic binary dumps, offering fast restarts but risking data loss between snapshots. AOF appends every write command, providing better durability; it can be rewritten to avoid file bloat. Hybrid persistence (RDB + AOF) combines fast recovery with minimal data loss. Choose RDB for read‑heavy workloads where occasional loss is acceptable, AOF for write‑intensive apps needing stronger durability, and hybrid for balanced requirements.
What is pipelining in Redis and why is it useful?
Pipelining batches multiple commands into a single network round‑trip, reducing latency. The client sends commands without waiting for replies, then reads all responses at once. This is useful for bulk inserts, fetching many keys, or executing a series of related commands. It improves throughput dramatically, especially over high‑latency links, while preserving command order. Interviewers look for awareness of network overhead and how pipelining mitigates it.
What is a Redis hash and when is it more efficient than storing JSON strings?
A Redis hash stores field‑value pairs under a single key, using a compact internal representation. It is more memory‑efficient than storing a JSON string because each field is stored separately, allowing Redis to use hash tables or ziplist encodings based on size. Use hashes for objects with many mutable fields, enabling partial updates without rewriting the whole value, and for faster field retrieval compared to parsing JSON.
What is the purpose of the Redis CONFIG REWRITE command?
CONFIG REWRITE updates the redis.conf file with the current in‑memory configuration, persisting runtime changes made via CONFIG SET. It writes only the parameters that differ from defaults, ensuring a clean config file. Use it after tuning settings like maxmemory or timeout to make changes survive restarts. Interviewers expect you to know that it does not affect parameters set via command‑line arguments.
What is a Redis hyperloglog and when would you use it?
A hyperloglog provides an approximate count of unique elements using only 12 KB, regardless of set size. It uses stochastic algorithms to estimate cardinality with ~0.81% error. Use it for analytics like counting distinct visitors, IP addresses, or hashtags where exact precision is unnecessary but memory efficiency is critical. Interviewers look for awareness of trade‑offs between accuracy and storage.
What is the difference between Redis' EXPIRE and PEXPIRE commands?
EXPIRE sets a key's time‑to‑live in seconds, while PEXPIRE uses milliseconds for finer granularity. Both update the TTL and return 1 if the timeout was set. Use PEXPIRE when you need sub‑second precision, such as short‑lived caches or rate‑limit windows. Interviewers check that you understand TTL semantics and the impact on expiration accuracy.
Intermediate
How does Redis clustering work and what are its limitations?
Redis Cluster shards data across 16384 hash slots distributed among master nodes. Clients compute the slot for a key and route requests to the appropriate master. Replicas provide failover; if a master fails, a replica is promoted. Limitations include no multi‑key transactions across slots, limited cross‑slot scripting, and the need for careful key design (hash tags) to co‑locate related keys. Understanding slot allocation and rebalancing is crucial for scaling while avoiding hot spots.
Describe how Lua scripting works in Redis and a scenario where it is preferred.
Redis executes Lua scripts atomically on the server, allowing multiple operations to run as a single transaction without race conditions. Scripts receive KEYS and ARGV arrays, enabling parameterized logic. Use cases include implementing custom rate limiting, atomic counters with complex conditions, or batch updates where a single round‑trip is critical. The interpreter is sandboxed, preventing external I/O, which ensures safety while offering flexibility beyond native commands.
How would you monitor Redis performance and detect bottlenecks?
Use Redis INFO for metrics like used_memory, hit_rate, and command_stats. Track latency with LATENCY HISTOGRAM and monitor slowlog for long‑running commands. Integrate with Prometheus exporters to visualize CPU, memory, and network. Identify bottlenecks by examining high eviction rates, low hit ratios, or spikes in command latency. Correlate with application logs to pinpoint heavy keys or inefficient patterns, then optimize with pipelining, appropriate data structures, or scaling the cluster.
How does Redis handle transactions and what are its limitations?
Redis transactions use MULTI/EXEC to queue commands and execute them atomically. Commands are processed sequentially without interleaving, guaranteeing consistency. However, there is no rollback on error; failed commands are still queued, and only runtime errors abort the transaction. Transactions cannot span multiple keys across slots in a cluster, and they lack isolation levels found in relational databases. Interviewers look for awareness of these constraints and appropriate use cases.
Explain how Redis' pub/sub model works and its limitations for reliable messaging.
Redis pub/sub delivers messages to all subscribers of a channel in real time. Publishers send messages without knowledge of subscribers. The model is fire‑and‑forget; if a subscriber disconnects, it loses messages, and there is no persistence or acknowledgment. Therefore, it is unsuitable for guaranteed delivery or replay scenarios. For reliable messaging, use Redis Streams or external brokers. Interviewers assess understanding of when to choose pub/sub versus durable queues.
How do you secure a Redis deployment in production?
Secure Redis by binding to private interfaces, disabling protected mode, and requiring authentication with ACLs. Use TLS for encrypted client‑server traffic, enable client‑side certificate verification, and restrict commands via ACLs per user role. Additionally, run Redis inside containers with limited privileges, apply OS‑level firewall rules, and rotate passwords regularly. Interviewers expect a layered security approach covering network, authentication, and runtime hardening.
How can you perform a bulk delete of keys matching a pattern without blocking Redis?
Use SCAN to iterate over the keyspace incrementally, filtering keys with the pattern, and delete them in small batches with UNLINK (non‑blocking) instead of DEL. This avoids blocking the event loop and keeps latency low. Example: while (cursor != 0) { cursor, keys = SCAN cursor MATCH pattern COUNT 1000; UNLINK keys; }. Interviewers expect you to know the difference between DEL (blocking) and UNLINK (asynchronous).
Explain the role of the Redis slowlog and how to use it effectively.
The slowlog records commands that exceed a configurable execution time threshold. It stores the command, execution duration, and timestamp. Use SLOWLOG GET to retrieve entries, and SLOWLOG RESET to clear them. Adjust the threshold with SLOWLOG LOG-SLOWER-THAN to capture relevant latency spikes. Analyzing slowlog helps identify inefficient queries, large payloads, or blocking operations, guiding optimization efforts.
Advanced
What are Redis streams and how do consumer groups work?
Redis streams are an append‑only log structure supporting high‑throughput messaging. Each entry has an ID and payload. Consumer groups allow multiple consumers to share the workload: each group tracks its own offset, and entries are delivered to one consumer per group, ensuring load balancing and fault tolerance. Pending entries list (PEL) enables replay of unacknowledged messages. This model is ideal for event sourcing, real‑time analytics, and reliable message queues.
Explain the difference between Redis' volatile‑LRU and allkeys‑LRU eviction policies.
Both policies evict least‑recently‑used keys when maxmemory is reached. volatile‑LRU only considers keys with an expiry set, preserving permanent data. allkeys‑LRU considers every key, regardless of TTL, allowing any data to be evicted. Choose volatile‑LRU when you have critical non‑expiring data you must keep, and allkeys‑LRU when you prefer uniform eviction based on usage. Interviewers expect you to discuss memory pressure handling and policy impact on data integrity.
How can you achieve high availability with Redis without using Redis Sentinel?
Deploy Redis Cluster with replicas for each master. Configure automatic failover so that if a master crashes, its replica is promoted. Use client libraries that support cluster topology changes to reconnect transparently. Additionally, run multiple independent clusters behind a load balancer and implement application‑level fallback. While Sentinel provides dedicated monitoring, clustering’s built‑in replica promotion offers HA without extra processes, though it lacks some Sentinel‑specific alerts.
Describe how Redis' memory eviction works when maxmemory is reached.
When maxmemory is hit, Redis applies the configured eviction policy to free space. Policies include noeviction (reject writes), allkeys‑LRU, volatile‑LRU, allkeys‑LFU, volatile‑LFU, and random variants. The algorithm selects keys based on recency or frequency, or randomly, and removes them until enough memory is reclaimed. Understanding policy choice is crucial: LFU favors frequently accessed data, while LRU favors recent usage. Interviewers probe your ability to balance performance and data safety.
What are Redis modules and when would you consider using one?
Modules extend Redis with custom commands and data types written in C or Rust. They allow functionality like full‑text search (RediSearch), graph queries (RedisGraph), or time‑series storage (RedisTimeSeries). Use a module when native Redis commands cannot meet specialized requirements, and you need high performance without external services. However, modules add binary dependencies and may affect upgrade paths, so evaluate trade‑offs before adoption.
How does Redis handle data replication lag and what metrics should you monitor?
Replication lag is the delay between master and replica applying write commands. Redis exposes replication offset and lag via INFO REPLICATION (master_repl_offset, replica_offset, lag). Monitor replica_lag to ensure it stays within acceptable bounds; high lag indicates network congestion or heavy write load. Use asynchronous replication settings (replica‑priority, replica‑read‑only) to balance consistency and availability. Interviewers look for proactive monitoring and mitigation strategies.
What is the purpose of the Redis CLIENT PAUSE command?
CLIENT PAUSE temporarily blocks new client connections for a specified duration, allowing administrators to perform maintenance tasks like backups without new traffic interfering. Existing connections continue processing, but new commands are rejected until the pause expires. It is useful for graceful shutdowns or to limit load spikes. Interviewers expect you to know its impact on latency and when to use it versus graceful shutdown scripts.
Common mistakes
- Confusing volatile‑LRU with allkeys‑LRU eviction policies
- Using DEL for bulk deletions causing server‑side blocking
- Assuming pub/sub guarantees message delivery
- Not accounting for cross‑slot key limitations in Redis Cluster
- Overlooking ACLs and TLS when securing production deployments
- Choosing RDB snapshots for write‑heavy workloads without considering data loss
Study plan
- Review core data structures and practice mapping use‑cases to each type
- Set up a local Redis Cluster, experiment with sharding, replicas, and failover
- Implement common patterns: caching, rate limiting, leaderboards, and streams
- Learn monitoring tools (INFO, slowlog, Prometheus) and practice tuning memory policies
- Secure a Redis instance with ACLs, TLS, and firewall rules
- Solve coding exercises that require pipelining, Lua scripts, and bulk operations
FAQ
Can Redis replace a traditional relational database?
Redis excels at fast key‑value access, caching, and real‑time analytics, but it lacks ACID transactions, joins, and complex querying. It can complement a relational DB for performance‑critical workloads, but replacing it entirely is rare unless the data model is simple and durability requirements are modest.
How do I choose between Redis Streams and a message broker like Kafka?
Redis Streams offers low‑latency, in‑memory messaging with consumer groups, suitable for moderate throughput and simple pipelines. Kafka provides durable, partitioned logs with high scalability and replay capabilities. Choose Streams for fast, lightweight use cases; Kafka for large‑scale, persistent event streaming.
What is the best way to benchmark Redis performance?
Use redis-benchmark to simulate realistic workloads, varying command types, pipeline depth, and key sizes. Combine with real‑world traffic patterns and monitor latency, throughput, and CPU. Benchmark both single‑node and clustered setups to understand scaling behavior.
Is it safe to run Redis in a Docker container in production?
Yes, if you configure persistent storage, limit memory, use host networking or proper port mapping, and apply security best practices (non‑root user, read‑only filesystem for configs). Monitoring container metrics is essential to avoid OOM kills.
How does Redis handle failover in a cluster without Sentinel?
In Redis Cluster, each master has replicas. If a master fails, the cluster’s failover algorithm promotes a replica automatically after a configurable timeout. Clients discover the new topology via MOVED/ASK redirects. This provides HA without separate Sentinel processes, though it lacks some health‑check features.
Related
Ready for your next interview?
Download MiPrep AI. Load your resume and the job description. Show up ready.
Free tier · No credit card · macOS 14+ · Windows 10+
Free tier · No credit card · Runs on your Mac or Windows machine