Skip to main content

CRE-2025-0177

Redis Slow Query Performance DegradationCritical
Impact: 6/10
Mitigation: 8/10

CRE-2025-0177View on GitHub

Description

Detects slow query execution in Redis that exceeds configured thresholds. Slow queries indicate performance problems that can impact overall Redis responsiveness and application latency.\n

Mitigation

IMMEDIATE ACTIONS:\n- Check slowlog: `redis-cli SLOWLOG GET 10`\n- Monitor current operations: `redis-cli --latency`\n- Identify blocking clients: `redis-cli CLIENT LIST`\n- Check CPU usage: `redis-cli INFO cpu`\n\nOPTIMIZATION:\n- Replace KEYS with SCAN:\n ```\n # Bad: KEYS pattern*\n # Good: SCAN 0 MATCH pattern* COUNT 100\n ```\n- Use pagination for large collections:\n ```\n ZRANGE key start stop\n LRANGE key start stop\n ```\n- Optimize Lua scripts:\n - Minimize Redis calls within scripts\n - Avoid complex computations\n- Break large operations into smaller batches\n\nCONFIGURATION:\n- Adjust slowlog threshold:\n `redis-cli CONFIG SET slowlog-log-slower-than 10000`\n- Increase slowlog size:\n `redis-cli CONFIG SET slowlog-max-len 128`\n- Enable latency monitoring:\n `redis-cli CONFIG SET latency-monitor-threshold 100`\n\nPREVENTION:\n- Regular slowlog analysis\n- Use appropriate data structures\n- Implement query timeouts in clients\n- Cache computation results\n- Use Redis modules for complex operations\n- Monitor and alert on slow query patterns\n

References