Prompt
Redis keeps causing latency spikes during bursts
Latest observation
Oct 25, 2026
OpenAI APIWeb search: off
Latency spikes during bursts in Redis are usually caused by one or more of these:
-
Single-threaded command execution
- Redis processes commands mostly on one main thread, so a burst can create a queue.
- Long-running commands block everything behind them.
-
Slow commands or big data structures
KEYS, largeLRANGE,SMEMBERS,HGETALL,ZRANGEover large sets, etc.- Large payloads increase serialization and network time.
-
Persistence overhead
- RDB snapshotting and especially AOF rewrite/fsync can introduce pauses or extra I/O pressure.
- Forking during snapshotting can cause latency on memory-heavy instances due to copy-on-write.
-
Memory pressure / eviction
- If Redis is near max memory, eviction can add work during bursts.
- Swapping is especially bad and causes severe latency spikes.
-
Networking or client behavior
- Too many small requests instead of pipelining.
- Connection churn, TLS overhead, or client-side blocking.
- Burst traffic can overwhelm the accept queue or NIC.
-
Background tasks
- Expiration cycles, rehashing, replication sync, failover, or cluster slot migration can contribute.
What to check first
- Run:
redis-cli LATENCY DOCTORredis-cli SLOWLOG GET 20redis-cli INFO statsredis-cli INFO memoryredis-cli INFO persistence
- Look for:
- Slow commands in
SLOWLOG latest_fork_usec,aof_rewrite_in_progress,rdb_bgsave_in_progress- High
used_memory, eviction count, swap activity - Large
instantaneous_ops_per_secspikes with latency
- Slow commands in
Common fixes
- Replace blocking commands with incremental alternatives:
KEYS→SCAN- large
LRANGE→ paging - large set/hash reads → chunked access
- Use pipelines or batching for bursts.
- Reduce payload sizes and large values.
- Tune persistence:
- Consider
appendfsync everysecinstead ofalways - Schedule snapshots/AOF rewrites away from peak traffic
- Consider
- Ensure Redis has enough RAM and is not swapping.
- Separate heavy workloads:
- Different Redis instances for cache vs. sessions vs. queues.
- If needed, scale out:
- Read replicas for read-heavy workloads
- Redis Cluster for sharding write load
If you want, I can help you diagnose this quickly
Paste the output of:
LATENCY DOCTORSLOWLOG GET 20INFO persistenceINFO memory
and I’ll tell you the most likely cause and the safest mitigation.
Brands