Advertisement
Advanced Redis, Expiration & Eviction

How would you diagnose and resolve a situation where important data is being unexpectedly evicted from Redis due to memory pressure?

Short answer

You would check the current maxmemory setting and eviction policy, review which keys are consuming the most memory, determine whether you actually need more available memory or a different eviction policy, and consider whether some data should be marked without an expiration and…

Save Redis mock interview
Advertisement
AModel answer
You would check the current maxmemory setting and eviction policy, review which keys are consuming the most memory, determine whether you actually need more available memory or a different eviction policy, and consider whether some data should be marked without an expiration and moved to a separate Redis instance using noeviction to guarantee it is never evicted.
Example

CONFIG GET maxmemory-policy INFO memory MEMORY USAGE somekey

Real-world example
A team discovers important configuration data was being evicted from a shared Redis cache under memory pressure, so they move that critical data to a separate Redis instance configured with noeviction to guarantee it is never accidentally removed.
Likely follow-ups
  • Should critical, non expendable data be kept in the same Redis instance as cache data at all?
  • How do you calculate how much memory your critical data actually needs?
Related topics