Redis is fast until one command, one oversized key, or one overloaded host turns a tiny delay into a queue.
That is the important mental model: Redis latency is rarely caused by Redis “randomly becoming slow.” In production, it is usually caused by work that became too large, too frequent, too concentrated, or too slow for a mostly single-threaded command-processing path.
Before increasing memory, adding replicas, or changing timeouts, find out where the time is being spent.
Is the request slow because:
- The application cannot borrow a Redis connection?
- The network path is slow?
- Redis is busy running expensive commands?
- One large key is creating long reads, writes, or deletes?
- The host pauses Redis because of CPU scheduling, swapping, persistence, or noisy neighbors?
The fix depends on the answer.
First, separate Redis latency from application latency
A slow API request that uses Redis does not automatically mean Redis is slow.
Your application may be waiting on:
- A saturated Redis client pool
- DNS lookup or TLS setup
- Network congestion
- Serialization or JSON parsing
- An overloaded Node.js event loop
- A retry queue
- A large Redis response crossing the network
- Redis command execution
Redis Slow Log is useful, but it only measures command execution time inside Redis. It does not include network I/O, client connection time, or the time required to send a response back to your application.
Start with these commands:
redis-cli -h REDIS_HOST -p 6379 --latency
This sends repeated PING commands and measures round-trip latency.
Then run this on the Redis host if possible:
redis-cli --intrinsic-latency 100
This checks whether the operating system is pausing Redis. High intrinsic latency often points to CPU contention, VM scheduling, container limits, noisy neighbors, or swapping - not a bad Redis command.
Now inspect Redis itself:
redis-cli SLOWLOG GET 20
redis-cli LATENCY DOCTOR
redis-cli INFO commandstats
Each command answers a different question:
| Command | What it helps you find |
|---|---|
SLOWLOG GET 20 | Commands that took a long time to execute inside Redis |
LATENCY DOCTOR | Latency events Redis observed and likely causes |
INFO commandstats | Commands called most often and cumulative time spent per command family |
redis-cli --latency | Client-to-Redis round-trip latency |
redis-cli --intrinsic-latency 100 | Scheduling pauses on the Redis machine |
Do not begin by guessing. First determine whether the bottleneck is in the client, network, Redis command loop, or host.
Redis has a queue, even when you did not create one
Redis can process ordinary commands extremely quickly because it avoids the complexity of a heavily threaded command model. But that also means an expensive command can delay cheap commands behind it.
Consider this request sequence:
Request A: HGETALL user:large-profile
Request B: GET feature-flag:checkout
Request C: INCR rate-limit:user:42
Request D: GET cart:123
If Request A operates on a giant hash, Requests B, C, and D may wait—even if their commands normally take microseconds.
This is why Redis can show short average latency while users experience occasional slow requests. One expensive operation creates a queue, and the queue affects unrelated keys.
When you investigate slow Redis, look for commands that are expensive because of:
- Large values or collections
- Unbounded reads
- Full keyspace scans
- Large response payloads
- Frequent writes to a hot key
- Expensive deletion or expiration work
- A workload spike after a deploy, campaign, or background job
Big keys are more dangerous than they look
A big key is not just a large string.
It can be:
- A JSON document containing an entire user profile
- A hash with hundreds of thousands of fields
- A set with millions of members
- A sorted set that stores an unbounded timeline
- A list used as a queue without a retention limit
- A stream that was never trimmed
Check a suspicious key:
redis-cli MEMORY USAGE cache:user:9842
This tells you how much memory the key and its value consume.
But memory usage alone does not tell the whole story.
A 10 MB key read once per day may be fine. A 300 KB key read, parsed, rewritten, and replicated thousands of times per second may be a serious problem.
Look for patterns like this:
HGETALL user:123
SMEMBERS permissions:all
ZRANGE leaderboard 0 -1 WITHSCORES
LRANGE events 0 -1
GET large:serialized-document
These commands are not always wrong. They become risky when the data behind them grows without a bound.
Replace full reads with bounded reads
This reads every field in a hash:
HGETALL user:123
If the hash grows, Redis must read and return everything.
If your API needs only three fields, ask for three fields:
HMGET user:123 name plan feature_flags
This returns an entire leaderboard:
ZRANGE leaderboard 0 -1 WITHSCORES
A safer API response usually has a limit:
ZREVRANGE leaderboard 0 99 WITHSCORES
The practical rule is simple:
A Redis key should have a known maximum size, and every read should have a known maximum response size.
If you cannot answer how large a key can become, you do not yet have a Redis data model. You have an unbounded production risk.
Blocking commands can stall unrelated traffic
The classic dangerous command is:
KEYS *
It looks convenient, especially in a debugging shell. But it scans the entire keyspace in one operation. On a large database, that can delay every other client request.
Never use this in production code:
const keys = await redis.keys('session:*');
Use incremental scanning:
let cursor = '0';
do {
const [nextCursor, keys] = await redis.scan(cursor, {
MATCH: 'session:*',
COUNT: 1000
});
cursor = nextCursor;
for (const key of keys) {
// Process keys in bounded batches.
}
} while (cursor !== '0');
SCAN does not guarantee a perfectly fixed snapshot of the keyspace. Keys can appear, disappear, or be returned more than once while scanning. That is usually acceptable for maintenance, cleanup, diagnostics, and migration tasks. If your operation requires strict consistency, you need a different design - not a larger KEYS command.
The same approach applies to large collections:
SSCAN user:permissions 0 COUNT 1000
HSCAN user:profile 0 COUNT 1000
ZSCAN leaderboard 0 COUNT 1000
Deleting one key can cause a latency spike
Large deletes are another common surprise.
This command removes a key synchronously:
DEL large:customer-export
For a large hash, set, sorted set, list, or string, Redis may spend noticeable time freeing memory. During that work, other commands can wait.
Use UNLINK for large keys:
UNLINK large:customer-export
UNLINK removes the key from the keyspace immediately and moves memory reclamation to a background thread.
That reduces blocking on the main command-processing path, but it is not a free pass to create massive keys. If your application continuously creates and deletes huge values, you still have a data-shape and memory-churn problem.
Slow commands often reveal a bad data model
Suppose Slow Log repeatedly shows this:
HGETALL product:catalog
The wrong response is usually:
Increase Redis memory.
Add another node.
Increase the timeout.
The better questions are:
- Why is the entire catalog stored in one hash?
- Why does one request need every product?
- Can products be partitioned by category, region, or page?
- Can the API read only the required fields?
- Should search use a search index instead of a giant hash?
- Should a highly cacheable response live at the CDN layer instead?
Redis performance is often a product of data shape, not Redis tuning.
For every key, define:
- How large can this key become?
- How frequently is it read?
- How frequently is it written?
- What happens when it expires?
- What happens when it is deleted?
- What is the worst-case response size?
If the answer to any of these is “it keeps growing,” fix that before scaling infrastructure.
Hot keys can overload Redis without being large
A hot key is a key requested far more often than other keys.
It may be tiny:
feature-flags:global
homepage:feed
rate-limit:anonymous
product:flash-sale
session:popular-user
A global feature-flag key read by every request can become a bottleneck. A flash-sale product can create a sudden traffic funnel. A rate limiter that checks Redis for every static asset can generate unnecessary load.
The symptom looks like “Redis is slow everywhere,” but the root cause is often one key receiving disproportionate traffic.
Possible fixes include:
- Keep a short-lived in-process cache for globally shared data
- Reduce duplicate reads within a single request
- Use request coalescing for simultaneous cache misses
- Add read replicas when stale reads are acceptable
- Move static or public cacheable data to a CDN
- Partition the workload if the data model allows it
- Add expiration jitter to avoid synchronized cache refreshes
Do not copy hot keys blindly. First decide whether local caching or replica reads are safe for that data’s consistency requirements.
Expiration storms create hidden load spikes
A cache can be healthy at 10:59 AM and failing at 11:00 AM because thousands of keys expire together.
This pattern creates synchronized expiry:
await redis.set(`product:${id}`, JSON.stringify(product), {
EX: 3600
});
If a bulk process writes 100,000 keys with the same one-hour TTL, many of them become stale at the same moment.
That creates a chain reaction:
Many keys expire
→ many cache misses
→ many database reads
→ slower database queries
→ longer API requests
→ retries
→ more Redis and database pressure
Add bounded jitter:
const baseTtlSeconds = 3600;
const jitterSeconds = Math.floor(Math.random() * 300);
await redis.set(`product:${id}`, JSON.stringify(product), {
EX: baseTtlSeconds + jitterSeconds
});
Jitter spreads the work. It does not replace correct cache invalidation, request coalescing, or database capacity planning—but it prevents independent keys from failing at the same time.
A production incident workflow
When Redis latency spikes, work through this sequence:
-
Confirm scope
Is one application slow, one Redis node slow, one region slow, or every client slow? -
Measure client round-trip latency
Runredis-cli --latencyfrom a similar network location as the affected application. -
Check host scheduling
Runredis-cli --intrinsic-latency 100on the Redis host if possible. High values indicate host-level pauses. -
Inspect Redis execution
RunSLOWLOG GET 20,LATENCY DOCTOR, andINFO commandstats. -
Search for dangerous shapes
Look forKEYS, unbounded ranges,HGETALLon huge hashes, oversized JSON values, large deletes, and expensive Lua scripts. -
Inspect key growth
Measure suspicious values withMEMORY USAGEand identify keys that can grow without limits. -
Check the client
Inspect Redis client-pool saturation, retry volume, command timeouts, serialization time, and event-loop delay. -
Check recent changes
A new deploy, feature flag, bulk import, traffic campaign, background job, or TTL change may have changed command patterns. -
Fix the workload first
Bound reads, useSCAN, split large keys, useUNLINK, reduce hot-key pressure, and add expiry jitter.
The rule that keeps Redis fast
Redis stays fast when each operation is small, bounded, and predictable.
It slows down when one key grows forever, one command scans too much, one hot key attracts all traffic, or one host pause creates a queue behind the command loop.
Before adding memory or nodes, find the exact command, key, or workload shape that changed. That is usually where the real fix lives.



