Redis

Use Cases Interview Questions

Use Cases interview questions for Redis — fundamentals through advanced scenarios.

  • 20Questions with answers
  • 3Difficulty levels

Questions (20)

Browse beginner, intermediate, and advanced questions with answers — hide them when you want to self-test.

Question 1
Interview Beginner
Question

How would you store sessions in Redis, and what product choice is persistence here?

Answer:

Session store: a STRING or HASH per session id with EXPIRE matching the cookie. HASH lets you HSET lastSeen without rewriting the blob. Losing Redis here logs everyone out, so persistence and replicas are product decisions, not just ops.

Question 2
Interview Beginner
Question

How do you implement a basic rate limit with Redis?

Answer:

Rate limiting: INCR of a window key plus EXPIRE on the first increment is the basic limiter. Sliding windows use ZSET with timestamps as scores and ZREMRANGEBYSCORE. Fixed windows are simpler and burst at boundaries.

Question 3
Interview Beginner
Question

How do you model a leaderboard, and why not rebuild it on every read?

Answer:

Leaderboards: ZSET score is the rank metric; ZREVRANGE gives top-N. Ties need a second score or lexicographic member. Do not rebuild the ZSET from SQL on every read; increment with ZINCRBY.

Question 4
Interview Beginner
Question

How does a safe Redis lock get released without deleting someone else lock?

Answer:

Distributed lock: SET lock:order NX EX seconds is the basic lock. Release with a Lua compare-and-DEL of the token. Locks without a token DEL are unsafe; any client could drop someone else lock.

Question 5
Interview Beginner
Question

Why is LIST a weak job queue compared with STREAM?

Answer:

Job queue: LIST LPUSH/BRPOP is a simple queue; crashed workers lose the popped job. STREAM plus XREADGROUP and XACK retries pending entries after XAUTOCLAIM. That is why STREAM replaced LIST for serious queues.

Question 6
Interview Beginner
Question

When is Redis GEO enough, and when is it not?

Answer:

GEO: GEOADD plus GEORADIUS or GEOSEARCH for drivers near here. Radius queries on huge sets still scan a geohash range. For nationwide search you shard by region keys, not one global ZSET.

Question 7
Interview Beginner
Question

When would you count unique visitors with HyperLogLog versus a SET?

Answer:

Unique visitors: HyperLogLog PFADD per day; exact uniques if the set fits in a SET. Billing uses SET or a database. HyperLogLog is for dashboards.

Question 8
Interview Intermediate
Question

How do idempotency keys in Redis stop double charges?

Answer:

Idempotency keys: SET idem:orderId NX EX 86400 around a payment. NX failure means already processed. Combine with the business record; Redis expiry must outlive retries.

Question 9
Interview Intermediate
Question

Where should feature flags live so allkeys-lru cannot evict them?

Answer:

Feature flags and config: a HASH of flags with Pub/Sub invalidation. allkeys-lru must not evict this key—use a separate instance or volatile-* only on cache keys. Mixing flag store and cache eviction is an outage.

Question 10
Interview Intermediate
Question

How do you deduplicate events, and when is Bloom the wrong structure?

Answer:

Dedup of events: SET with NX or Bloom BF.ADD for did we see this event id. Bloom false positives drop events; that may be wrong. For exactly-once, NX on a SET or STRING plus persistence.

Question 11
Interview Intermediate
Question

How do you implement a sliding session TTL without stamping Redis on every click?

Answer:

Sliding session: GET plus EXPIRE refresh, or HASH plus EXPIRE. Sliding TTL on every request can stampede Redis; refresh only when remaining TTL is below a threshold.

Question 12
Interview Intermediate
Question

How would you model online presence without trusting Pub/Sub as the roster?

Answer:

Multi-player presence: Pub/Sub for ticks, SET or ZSET of online user ids with a short TTL refreshed by heartbeat. Expired members leave. Do not trust Pub/Sub as the roster; the SET is the roster.

Question 13
Interview Intermediate
Question

How do you schedule delayed jobs with ZSET without two workers grabbing one job?

Answer:

Fair job scheduling: ZSET score equals run-at timestamp, workers ZRANGEBYSCORE plus ZREM in Lua. Without Lua, two workers grab the same job. This is a classic EVALSHA use case.

Question 14
Interview Intermediate
Question

What goes wrong when you cache full HTML pages as huge STRING values?

Answer:

Cache of rendered pages: STRING with TTL jitter, cache-aside from origin. Negative cache 404s briefly. Huge HTML values become big keys; compress or fragment.

Question 15
Interview Advanced
Question

Why is Redlock not a complete correctness story for distributed locks?

Answer:

Redlock caveats: pause-the-process, clock drift, and majority failure modes mean Redlock is not a silver bullet for correctness. For a mutex around a side effect, a single Redis with fencing tokens or an external consensus store may be clearer. Know Kleppmann critique in interviews.

Question 16
Interview Advanced
Question

What still fails if a lock holder pauses past EX and then writes?

Answer:

Distributed lock fencing: the lock token is not enough if the holder pauses past EX and another holder starts; the slow holder then writes anyway. A monotonically increasing fencing token checked by the storage layer is the real fix. Redis lock EX only bounds the critical section if the work is short.

Question 17
Interview Advanced
Question

How do you rate-limit on Cluster without a hot {global} counter?

Answer:

Rate limit across Cluster: the counter key must not hot-slot a single {global} tag. Shard by user id. A single global INCR is a Cluster bottleneck.

Question 18
Interview Advanced
Question

How would you store per-user inboxes without creating unbounded STREAM keys?

Answer:

Inbox and notifications: STREAM per user with MAXLEN approximate, or a LIST of recent ids. STREAM consumer groups if multiple notification workers. Per-user keys need hash tags only when multi-key ops apply.

Question 19
Interview Advanced
Question

Where does Redis GEO stop and a search engine start?

Answer:

Geo plus search: Redis GEO does not replace Elasticsearch. Use GEO to shortlist ids then hydrate. Interviewers want that boundary.

Question 20
Interview Advanced
Question

When should you refuse to put a problem in Redis?

Answer:

When not to use Redis: large relational queries, unbounded datasets that do not fit RAM, and strong multi-key transactions across entities. Redis is memory-first. For those, use a disk database and cache-aside.

Practice with AI mock interviews

Run Redis mock interviews with AI follow-ups, instant feedback, and analytics on AiLx.

Free to start · No credit card required