Interview › Databases & Caching
What are Redis eviction policies (e.g., LRU, LFU, volatile vs allkeys)?
Databases & Caching · Advanced level
Answer
Redis eviction policies decide what Redis removes when maxmemory is reached. allkeys policies can evict any key; volatile policies evict only TTL keys; LRU and LFU approximate recency and frequency; noeviction makes writes fail.
Technical explanation
LRU approximates least recently used; LFU approximates least frequently used; volatile policies protect non-TTL keys but can fail writes if no TTL keys are eligible.
TTL jitter prevents synchronized expiry and thundering herds.
Memory alerts must fire before maxmemory to avoid eviction storms or write failures.
Hands-on example
Policy example for pure cache:
maxmemory-policy allkeys-lfu
SETEX product:v2:123 642 <json>
642 seconds = 600 base + random jitter.
Incident checks:
INFO memory
INFO stats
CONFIG GET maxmemory-policy
Watch evicted_keys, keyspace_hits, keyspace_misses, app cache errors, and RDS fallback load.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Databases & Caching interview questions
- What is Amazon RDS, and what does it manage for you versus self-managed databases?
- What database engines does RDS support?
- What is the difference between RDS and Aurora?
- What is Multi-AZ in RDS, and how does automatic failover work?
- How long does an RDS Multi-AZ failover typically take, and what triggers it?
- What is the difference between Multi-AZ and a read replica?
- When would you use a read replica, and can it become a standalone database?
- Can a read replica be in a different region, and why would you do that?