Redis Load Testing: What to Measure and How to Run It
Redis load testing through your app path: slow commands, hot and big keys, eviction, persistence stalls, plus a numbered plan and a worked example.
To load test Redis, send realistic traffic through the application that uses it and watch Redis-side metrics while the load runs: command latency, operations per second, hit ratio, evictions, memory and connected clients. Then run an isolated benchmark to learn the server’s own ceiling. The gap between the two tells you whether the limit is Redis or the code around it.
For the stream data type specifically, see load testing Redis Streams. This guide covers the rest of Redis.
Prerequisites
- A Redis instance you are authorised to load, sized and configured like production.
- Read access to
INFO,SLOWLOGand your metrics dashboards for that instance. - The application endpoints that use Redis, reachable from your load generators.
- A target: peak requests per second, read/write ratio, and a latency budget.
Test the application path first, benchmark second
There are two kinds of Redis test, and they answer different questions.
An isolated benchmark points a tool straight at Redis. redis-benchmark ships with Redis and prints throughput and latency for a set of commands such as SET and GET, with options for payload size, pipelining and client count. memtier_benchmark is a separate tool with more control: configurable read/write ratios, key distributions, data sizes, threads, and cluster mode. Both are good at one thing, finding the server’s ceiling for a synthetic command mix on a given instance.
Their limits matter. The command mix is the one you chose, not the one your code produces. Keys are usually uniform random, so there are no hot keys, and values are usually one fixed size, so there are no big keys. They also skip serialisation, client pool waits, retries and the code that decides what to cache. A benchmark reports a million operations a second while your checkout endpoint times out on a pool wait.
An application-path test drives the real endpoints with a realistic mix and lets the application generate the Redis commands. It finds the problems your code creates: an N+1 pattern of lookups, a KEYS call in an admin path, a pool that is too small. It is also the only test that tells you what a user feels. Run it first. Use the isolated benchmark afterwards, to separate “Redis is at its limit” from “the application is wasting Redis”.
Why one slow command hurts everyone
Redis runs commands on a single main thread. Newer versions offload network I/O to extra threads, but command execution stays serial. That makes Redis fast for cheap commands and unforgiving for expensive ones. While a slow command runs, every other client waits in line.
Commands that are cheap on a small dataset and expensive on a large one:
KEYS patternscans the whole keyspace. UseSCANin application code.HGETALL,SMEMBERS,LRANGE 0 -1andZRANGE 0 -1on collections with many elements return the whole collection.SORT,SUNIONand similar set operations scale with the size of the sets.DELon a huge key frees memory synchronously.UNLINKfrees it in the background.- Lua scripts and
MULTI/EXECblocks hold the thread for as long as the script runs.
If GET p99 jumps whenever a report job runs, the report is the cause. The SLOWLOG records commands that exceeded a time threshold (slowlog-log-slower-than, in microseconds), along with how long they took. Read it after every run. The SLOWLOG measures execution time, not time spent waiting in the queue, so a spike in client-side latency with an empty SLOWLOG points at queueing, network or the client pool.
Hot keys and big keys
A hot key receives a disproportionate share of traffic: a feature flag read on every request, a leaderboard, a global counter. A single instance handles one hot key well, because each read is cheap. The trouble appears when you scale out. In Redis Cluster, one key lives in one slot on one node, so a hot key pins its load to that node while the others idle. Adding nodes does not help.
A big key is a single key with a large value or a collection with an extreme element count. Commands that touch it are slow, and it causes a latency spike when it expires or is deleted. Big keys are usually accidents: a list that was never trimmed, a hash that collects one field per user.
Your test data decides whether either problem appears. If every virtual user reads a random key, you will not find a hot key. Reproduce the real access distribution: send a large share of requests to a handful of keys, and let some values grow to their real maximum size. Real traffic is skewed, and the test should be too.
Memory, maxmemory and eviction
Redis keeps the dataset in memory. The maxmemory setting caps it, and maxmemory-policy decides what happens at the cap. With noeviction, writes fail with an out-of-memory error once the limit is reached. With policies such as allkeys-lru, allkeys-lfu or volatile-lru, Redis evicts keys to make room. Which one is right depends on whether Redis is a cache (eviction is fine) or the system of record (it is not).
A short test will not reach the limit. Plan a test that does: fill the dataset to your expected production size first, then run load. Watch used_memory, evicted_keys and the hit ratio together. Eviction costs twice: the hit ratio falls, which pushes traffic to the database, and eviction work adds latency. If hit ratio drops while evicted_keys climbs, the cache is too small for the working set.
Persistence causes latency spikes
Persistence is where “Redis is fast” breaks most often. Two mechanisms matter.
RDB snapshots work by forking the process. Forking a process with a large dataset pauses the main thread while page tables are copied, and copy-on-write memory grows while writes continue during the snapshot. A write-heavy test during a snapshot shows both a latency spike and a memory jump.
AOF appends every write to a log. The appendfsync setting controls how often it is flushed to disk: always is safest and slowest, everysec flushes once a second, no leaves it to the operating system. Slow disks turn into slow writes. AOF rewrites fork the process as well.
Run with your production persistence settings, on the same kind of disk, long enough to cover a snapshot or rewrite. The latest_fork_usec field in INFO stats shows how long the last fork took.
Connections, pools and Redis Cluster
Each client connection costs memory and a file descriptor, and maxclients caps the total. Many application instances with large pools approach the limit unnoticed until a deploy scales the fleet up. Watch connected_clients and rejected_connections. A pool that is too small queues requests inside the application and adds latency that Redis never sees.
Redis Cluster adds its own checks:
- Slot imbalance. Keys hash into 16,384 slots spread across nodes. Hash tags (
{user:42}) force related keys into one slot, which is useful and also a way to build a hot node. Compare per-node operations per second during the run. - Cross-slot limits. Multi-key commands and transactions generally require all keys in one slot. Code that worked on a single instance fails with
CROSSSLOTerrors on a cluster. Test against a cluster if you will deploy to one. - Resharding and failover. Moving slots or promoting a replica during load shows how clients handle
MOVEDandASKredirects and how long errors last.
With replicas, measure replication lag while writes run at peak rate, since reads from a lagging replica return stale data, and test a failover under load.
What to measure
Record these as time series during the run, not as end-of-run averages.
| Signal | Where it comes from | What it tells you |
|---|---|---|
| Command latency (p50, p95, p99) | Client side, plus LATENCY tools on the server | User-visible cost, and spikes from slow commands or forks |
| Operations per second | instantaneous_ops_per_sec in INFO stats | Throughput against your target |
| Hit ratio | keyspace_hits and keyspace_misses | How much traffic reaches the database |
| Evictions and expired keys | evicted_keys, expired_keys | Memory pressure versus normal TTL churn |
| Memory | used_memory, fragmentation ratio | Distance to maxmemory |
| Connected and blocked clients | connected_clients, blocked_clients | Pool sizing and queueing |
| Slow commands | SLOWLOG GET | Which command blocked the thread |
| Replication lag | INFO replication | Staleness and failover readiness |
Hit ratio is also a database-load metric: a fall from 98 to 90 percent multiplies database reads by five, since misses go from 2 to 10 percent of requests. That is the mechanism behind the cache stampede and the reason a cache purge test exists. For the HTTP-layer view of hits and misses, see the academy page on cache hit and miss testing.
Test plan
- Write down the target. Peak requests per second, read/write ratio, key count, value sizes and the latency budget for the endpoints that use Redis.
- Build a production-like instance. Same version, size, persistence settings,
maxmemoryandmaxmemory-policy, same topology (single, replicated or cluster). - Load the dataset. Fill it to production size with realistic key and value distributions, including a few large values and a skewed set of popular keys.
- Take a baseline. Run an isolated
memtier_benchmarkorredis-benchmarkto record the server’s ceiling for your command mix and value size. Keep the result. - Run the application-path test. Ramp virtual users through the endpoints that use Redis. Hold at peak long enough to include a snapshot or AOF rewrite.
- Add the awkward events. Trigger an expensive command (the admin report, say), a snapshot, and a flush of one namespace while load is running.
- Raise the load past the target. Find where latency leaves the budget and record which signal moved first.
- Read the server’s view. Line up SLOWLOG,
INFOsnapshots and per-node figures with the latency curve. - Change one thing and rerun. Pool size, eviction policy, a trimmed key,
SCANin place ofKEYS.
A benchmark command for step 4 looks like this:
memtier_benchmark -s redis.staging.internal -p 6379 \ --threads=4 --clients=50 --ratio=1:10 \ --data-size=1024 --key-pattern=G:G --key-stddev=2000 \ --test-time=300 --hide-histogram--ratio=1:10 sets one write per ten reads, and the Gaussian key pattern skews access towards a set of popular keys. Check memtier_benchmark --help on your version for the exact options.
Worked example
The numbers below are hypothetical, to show how to read the results. They are not benchmarks.
A product page reads its product data and a per-user price from Redis. The target is 2,000 page requests per second with a page p95 under 300 ms.
The isolated memtier_benchmark baseline shows the instance handling far more than the target, with GET p99 at 1 ms. Redis is not the limit.
The application-path test ramps to 2,000 requests per second. Page p95 is 180 ms for five minutes, then jumps to 900 ms for about eight seconds, then recovers. Redis GET p99 follows the same pattern, from 1 ms to 400 ms. The SLOWLOG has one entry from that window: a HGETALL on a hash holding every price override, taking 380 ms. A scheduled job calls it every five minutes.
The fix is to split the hash into per-product keys and read only what the page needs. The rerun holds p95 at 175 ms through the whole run, with an empty SLOWLOG.
How to run it in MaxoPerf
MaxoPerf tests Redis through your application’s API, which is the application-path test above.
- Create a test and upload a k6 script, or any other supported executor, that calls the endpoints which read and write Redis. Use a realistic key distribution in the requests, for example a weighted list of product IDs.
- Set the virtual users, ramp-up and hold time in the test configuration, and pick the location plan. If Redis sits in a private network, use a private datacenter (BYOC) location so the runners reach your API.
- Store tokens as project secrets and bind them to the test, so they do not appear in the script.
- Add SLA gates on p95 latency and error rate for the endpoints, so a run that leaves the budget is marked failed.
- While the run is live, read
INFOand SLOWLOG from Redis on your side and note the timestamps. Compare them with the MaxoPerf latency chart afterwards.
If you want to call Redis directly from the test, the Locust executor loads a client library through Taurus’s pip-install service, as in the Redis Streams guide. Only load a Redis instance you are authorised to test, and use a separate key prefix so cleanup is easy.
Troubleshooting
- Latency spikes with an empty SLOWLOG. The delay is queueing, a fork pause or the client pool. Check
latest_fork_usecand your pool wait metrics. - Throughput is flat while Redis CPU is low. The load generator or the client pool is the limit. Raise pool size or add runners and rerun.
- Hit ratio is high but the database is still busy. The misses concentrate on expensive queries, or a few hot keys expire together. Stagger TTLs and look at which keys miss.
OOM command not allowederrors. The dataset reachedmaxmemoryundernoeviction. Raise memory, shorten TTLs or change the policy.CROSSSLOTerrors only on the cluster. A multi-key command spans slots. Use hash tags or split the command.
Questions this article answers
How do you load test Redis?
Drive load through the application endpoints that use Redis, at a realistic mix of reads and writes, and record Redis-side metrics at the same time: command latency, operations per second, hit ratio, evictions, memory and connected clients. Add an isolated benchmark with redis-benchmark or memtier_benchmark to find the server's ceiling, then compare the two.
What is a good Redis benchmark tool?
redis-benchmark ships with Redis and is quick for a first number. memtier_benchmark, from Redis Ltd, gives more control: key patterns, read/write ratios, data sizes, multiple threads and connections. Both measure synthetic commands, so they show the server's limit and not how your application behaves.
Why is Redis slow under load when CPU looks fine?
Redis executes commands on one main thread, so a single slow command delays every command queued behind it, while overall CPU on a multi-core host looks low. Check SLOWLOG, big keys, Lua scripts and fork pauses from persistence before assuming the network or the client.
How do you find a hot key in Redis?
Run your load test and watch per-key access as well as totals. redis-cli has a hot-key scan mode that works with an LFU eviction policy. The MONITOR command shows live commands but is expensive, so use it briefly and never on a loaded production instance. A hot key also shows up as one cluster node running hotter than the rest.
Should you load test Redis in production?
Test against a production-like environment with the same instance size, persistence settings, maxmemory and data volume. Production tests risk evictions, latency spikes and shared-capacity effects on real users. If you must test in production, cap the rate and use separate key prefixes.