DevOpsInterviewPrep logo
← 🚨 Debugging Production
Foundational

Redis troubleshooting: memory accounting, eviction and latency evidence

Diagnose Redis memory and latency by separating eviction-accounted usage, process RSS, cache behavior and command execution. Explain noeviction, volatile policies and why an empty slowlog can miss client-visible delays.

TL;DR: Redis memory pressure can cause evictions, rejected writes or host-level failure, depending on policy and memory accounting. Compare those outcomes with latency and cache-miss evidence before raising maxmemory or weakening persistence.

Establish whether the data may be discarded

A recomputable product-page cache and a queue containing the only copy of pending work have different eviction requirements. An eviction policy suitable for the cache can destroy the queue's correctness. Document what is authoritative and separate workloads with incompatible loss tolerance before tuning a shared instance.

Redis's eviction reference describes policies including allkeys-lru, volatile-lru and noeviction. All-key policies can select from the whole keyspace; volatile policies select keys with expiry. With no eligible expiring keys, a volatile policy cannot create space by evicting persistent keys. noeviction rejects applicable memory-growing operations instead of discarding keys; it does not make the service infinitely available.

The same reference explains that some replication and persistence buffers are excluded from the memory compared with maxmemory. A large operation can also temporarily exceed that limit. Therefore maxmemory is not a hard ceiling on process resident memory. Leave measured headroom inside the host or container limit.

rendering diagram…

The paths can overlap. An eviction spike can protect part of the memory budget while increasing load on the database that serves cache misses.

Read memory and cache evidence separately

Use an authorized Redis connection to collect a small snapshot. These are diagnostic Redis commands, not shell commands; select the intended instance and authenticate through the approved client configuration before running them. Slowlog entries can contain application arguments, so protect and redact captured output.

INFO memory
INFO stats
INFO commandstats
SLOWLOG GET 10

The INFO reference defines fields such as allocated memory, resident memory, eviction/expiry counters and command statistics. Compare counter deltas over the incident window. A lifetime total of a million evictions says little about what changed in the last minute. Missing fields can reflect version or product differences; they are not zero measurements.

ObservationPlausible mechanismEvidence that separates it
Evictions and misses rise togetherWorking set exceeds retained cacheKey sizes, access pattern and policy
Writes fail but reads still workMemory policy rejects growthCommand errors and eligible eviction keys
RSS grows beyond accounted usageAllocator, buffers or other overheadMemory fields and host/container pressure
Client latency rises with quiet slowlogDelay outside measured command executionClient queue, network and server scheduling

Work through a cache-induced database incident

In a fictional ten-minute window, the service records 80,000 cache hits and 20,000 misses. Its hit ratio is 80,000 / 100,000 = 80%. The previous comparable window had 95,000 hits and 5,000 misses. Total lookups stayed constant, but fallback reads rose fourfold.

If every miss triggers one database read in this simplified case, the database now sees 20,000 rather than 5,000 fallback reads. Request coalescing or multi-get behavior would change that mapping, so confirm it in traces. Check whether the cache's key sizes or TTLs changed with the last release and whether the new access pattern still fits the selected policy.

Do not immediately raise maxmemory to the container's full limit. That can trade a cache-miss problem for process termination. Estimate resident-memory and persistence overhead under a representative peak, then test a bounded adjustment or reduce the cache footprint. Verify database pressure as well as Redis memory afterward.

A quiet slowlog has a limited meaning

Redis SLOWLOG records commands exceeding its configured execution-time threshold; it excludes time spent communicating with the client. A client can wait for a pool slot or experience a network delay without creating a slow command entry. The threshold and retention also constrain what absence tells you.

The latency diagnosis guide covers expensive commands, persistence activity and host effects. Correlate a suspected fork or persistence pause with timestamps and server/host metrics. Removing durability because an unrelated client queue is slow changes the data-loss contract without addressing the measured delay.

Self-check: a volatile-lru instance has no keys with expiry and rejects a new write under memory pressure. Will repeatedly retrying that write make the policy evict old persistent keys? No. Those keys are ineligible. Decide whether the workload should expire or evict data, free capacity deliberately, or separate authoritative state from disposable cache entries.

RELATED CONCEPTS
PRACTICE THIS IN REAL QUESTIONS