LinuxCommandLibrary

redis-benchmark

Benchmark Redis performance

TLDR

Run full benchmark

$ redis-benchmark
copy

Run benchmark on a specific Redis server
$ redis-benchmark -h [host] -p [port] -a [password]
copy

Run a subset of tests with default 100000 requests
$ redis-benchmark -h [host] -p [port] -t [set,lpush] -n [100000]
copy

Run with a specific script
$ redis-benchmark -n [100000] script load "[redis.call('set', 'foo', 'bar')]"
copy

Run benchmark by using 100000 [r]andom keys
$ redis-benchmark -t [set] -r [100000]
copy

Run benchmark by using a [P]ipelining of 16 commands
$ redis-benchmark -n [1000000] -t [set,get] -P [16]
copy

Run benchmark [q]uietly and only show query per seconds result
$ redis-benchmark -q
copy

SYNOPSIS

redis-benchmark [-h host] [-p port] [-s socket] [-a password] [-c clients] [-n requests] [-d size] [-P numreq] [-t tests] [OPTIONS]

PARAMETERS

-h
    Server hostname to connect to (default: 127.0.0.1).

-p
    Server port to connect to (default: 6379).

-s
    Server socket path for Unix domain sockets (overrides host and port).

-a
    Password for Redis authentication.

-u
    Connect to Redis using a URI string (e.g., redis://user:pass@host:port/db).

-c
    Number of parallel connections (clients) to open during the benchmark (default: 50).

-n
    Total number of requests to execute across all clients (default: 100000).

-d
    Data size of SET/GET values in bytes (default: 3).

-P
    Pipeline numreq requests. If 0, don't pipeline (default: 1).

-t
    Comma-separated list of specific tests/commands to run (e.g., ping,set,get,lpush).

-q
    Quiet mode; only show requests per second (RPS) values.

-N
    Skip N requests to pre-populate the dataset before starting the actual benchmark.

-csv
    Output results in CSV format.

--json
    Output results in JSON format (available in newer Redis versions).

--show-latency-dist
    Display a detailed latency distribution graph at the end of the benchmark.

--cluster
    Enable cluster mode for testing Redis Cluster instances.

DESCRIPTION

redis-benchmark is a command-line utility included with Redis that simulates client connections to a Redis server to measure its performance. It can test various Redis commands like PING, SET, GET, LPUSH, LPOP, etc., under different load conditions. Users can configure the number of concurrent clients, total requests, data size, and pipelining.

The tool outputs critical metrics such as requests per second (throughput), latency (minimum, maximum, average, and percentiles), and error rates. It is an invaluable tool for understanding how a Redis instance behaves under specific workloads and for identifying potential bottlenecks or validating optimizations.

CAVEATS

redis-benchmark runs on the client machine, so network latency and the client machine's resources (CPU, memory, network I/O) can significantly influence results. It is best to run it from a machine with good network proximity to the Redis server and sufficient available resources to avoid skewing the measurements.

The benchmark simulates synthetic workloads. Real-world application patterns might involve more complex command sequences, specific data structures, or transaction logic that redis-benchmark does not fully replicate. Options like --show-latency-dist or --latency-history can consume significant memory and CPU on the client, potentially impacting high-throughput benchmarks.

BENCHMARKING STRATEGY

It's recommended to run benchmarks multiple times and average the results to account for transient system variations. Vary parameters such as client connections (-c), total requests (-n), and data size (-d) to understand performance characteristics across different scales and identify potential bottlenecks under specific load profiles.

IMPACT OF PIPELINING

Using the -P option for pipelining significantly impacts observed throughput. Pipelining allows sending multiple commands to the server without waiting for individual replies, which dramatically reduces the impact of network round-trip time (RTT). This showcases Redis's ability to process commands efficiently in high-latency network environments or when dealing with a large number of concurrent operations.

HISTORY

redis-benchmark has been a standard utility distributed with Redis since its early versions. It has continuously evolved alongside the Redis server, adding support for new features such as pipelining, authentication, TLS encryption, and Redis Cluster. Its primary design goal remains to provide a simple, quick, and effective way to assess Redis performance under various synthetic loads.

SEE ALSO

redis-cli(1), top(1), iostat(1), sar(1)

Copied to clipboard