Redis & Caching (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
How do you troubleshoot Redis Latency and High CPU?
senior LevelredisAdvanced Internals
In Simple Words:
- Check the Slowlog:
SLOWLOG GET 20(identifies commands exceedingslowlog-log-slower-than). - Run
redis-cli --latencyandredis-cli --intrinsic-latencyto differentiate network vs engine latency. - Check CPU profile with
INFO commandstats(detects heavy commands likeKEYS,SMEMBERS, or largeHGETALL). - Inspect
used_memory_rssvsused_memory(ratio > 1.5 indicates severe memory fragmentation; triggerMEMORY PURGEor active defragmentation).