Scrivio Interview library

Redis

24 questions in 8 subtopics.

Data structures

ConceptFoundations7 min read
Name the core Redis data types and give one realistic use for each: strings, hashes, lists, sets, sorted sets, streams, bitmaps and HyperLogLog. Which commands would you use and what is their time complexity?
CodingFoundations7 min read
Implement a game leaderboard in Redis from a Spring Boot service: record a score, show the top 10 with scores, and show a player's rank. Give the Redis commands and the Spring Data Redis calls.
DebuggingIntermediate6 min read
Redis latency spikes to 200 ms every few minutes. redis-cli --bigkeys shows a hash with 4 million fields, and the slow log shows HGETALL and DEL on it. Explain why this hurts and how you would fix it without downtime.
LeadershipPrincipal6 min read
Redis started as a simple in-memory cache and now offers JSON documents, search, time series and vector similarity. Teams propose using it as a general database for new products. As the senior technical leader, how do you judge this, given how the ecosystem evolved?

Persistence with RDB and AOF

ConceptFoundations6 min read
Compare Redis RDB snapshots and AOF persistence. How does each work, what data can you lose after a crash, and what is the recommended combination?
ScenarioIntermediate7 min read
A Redis instance with 40 GB of data on a 64 GB machine is killed by the OOM killer every night at 02:00, and latency spikes during the day too. Persistence uses RDB at 02:00 and AOF everysec. Explain the cause and the fixes.
DesignAdvanced7 min read
Define backup, persistence and recovery standards for 150 Redis deployments used for caches, sessions, rate limits and a few queues. What differs per use case, and how do you test recovery?

Expiry and eviction

ConceptFoundations6 min read
How does key expiry work in Redis, and what is the difference between expiry and eviction? List the main maxmemory-policy options and say which one fits a pure cache.
DebuggingIntermediate7 min read
A Spring Boot service using Redis as a cache starts failing with 'OOM command not allowed when used memory > maxmemory', while the cache hit rate looked fine yesterday. What do you check and change?
ScenarioIntermediate7 min read
A product catalogue cache in Redis uses a fixed TTL of 10 minutes. Every 10 minutes the database CPU jumps to 100 percent for a few seconds. Explain the problem and give at least three mitigations.

Cache vs primary store

DesignIntermediate7 min read
Design the caching of product details in a Spring Boot service with Redis using cache-aside. Cover reads, writes, invalidation, serialization and what happens when Redis is unavailable.
ScenarioAdvanced7 min read
A team wants to use Redis as the primary store for shopping carts and order drafts to get low latency, with no relational database behind it. How do you evaluate the proposal and what conditions would you set?
LeadershipPrincipal6 min read
In 2024 Redis moved from the BSD license to source-available licenses, the Valkey fork was created under the Linux Foundation, and later Redis added an AGPL option. Your company runs hundreds of Redis instances and a managed offering. How do you decide your direction?

Distributed locks with Redis

CodingFoundations7 min read
Implement a simple lock in Redis so that only one instance runs a nightly job. Show the commands for acquiring and releasing it, and explain why a plain GET followed by DEL is wrong for release.
ConceptIntermediate7 min read
A team uses Redis locks (Redisson, Redlock-style) to make sure only one worker charges a customer. Explain the known weaknesses of Redis-based locks for correctness and what you would add or use instead.
DesignAdvanced8 min read
Teams across the company implement distributed locks in five different ways (Redis SET NX, Redisson, database advisory locks, ShedLock, ZooKeeper). Define a standard for when and how to use locks.

Pub/sub and streams

ConceptFoundations7 min read
Compare Redis pub/sub with Redis Streams. What happens to a message in each when a subscriber is offline, and which commands give at-least-once processing with consumer groups?
DesignIntermediate7 min read
A team proposes Redis Streams instead of Kafka for order events between six services, about 2,000 events per second, with a need to replay the last 7 days. How do you evaluate the choice?

Redis Cluster and Sentinel

ConceptIntermediate6 min read
Explain how Redis Cluster distributes keys and handles failover. What do MOVED and ASK redirections mean, and why does a multi-key command sometimes fail with CROSSSLOT?
DebuggingIntermediate6 min read
After a Redis Sentinel failover, a Spring Boot service using Lettuce keeps writing to the old primary, now a replica, and logs 'READONLY You can't write against a read only replica' for several minutes. What is wrong and how do you configure it correctly?
DesignAdvanced6 min read
Design the Redis topology for a multi-region e-commerce platform that uses Redis for sessions, carts and rate limits, with a regional failure tolerance requirement. What runs where, and what consistency do you accept?
LeadershipPrincipal6 min read
Your company runs about 400 self-managed Redis instances, several teams of on-call engineers maintain them, and cloud providers offer managed Redis-compatible services. As the senior technical leader, how do you decide between self-managing, a managed service and a mix?

Lua scripts and atomicity

CodingFoundations7 min read
Write a Redis Lua script for a fixed-window rate limiter that allows 100 requests per minute per API key, and call it from Spring Data Redis. Why is a script better than INCR followed by EXPIRE from Java?
DebuggingIntermediate7 min read
Redis stops responding to all clients for 8 seconds and clients log 'BUSY Redis is busy running a script'. A Lua script loops over thousands of keys found with SCAN inside the script. Explain the behaviour and how to fix it, including in Redis Cluster.