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 [options]

PARAMETERS

-h
    Server hostname (default: 127.0.0.1).

-p
    Server port (default: 6379).

-s
    Server socket (overrides host and port).

-a
    Password for Redis authentication.

-c
    Number of parallel clients (default: 50).

-n
    Total number of requests (default: 10000).

-d
    Data size of SET value in bytes (default: 3).

-k
    1=keep alive. 0=reconnect (default: 1).

-r
    Use random keys for SET/GET/INCR, random values for SADD. In order to randomize both keys and values use -r -r .

-P
    Pipeline requests. Default 1 (no pipeline).

-q
    Quiet. Just show query/sec values.

--csv
    Output in CSV format.

-l
    Loop. Run the tests forever.

-t
    Only run the comma separated list of tests. The test names are the same as the command names used in the output.

-I
    Idle mode. Just open N idle connections and wait.

--latency
    Measure latency in addition to throughput.

--threads
    Run in multi-threaded mode. Default 1 thread.

--help
    Show help message and exit.

DESCRIPTION

redis-benchmark is a utility included with Redis used to benchmark the performance of a Redis server. It simulates multiple clients sending commands to the server and measures the throughput (requests per second) and latency. It allows users to test different aspects of Redis performance, such as SET/GET operations, pipelining, and different data types. redis-benchmark can be useful for capacity planning, performance tuning, and identifying bottlenecks.
It provides configurable options for the number of clients, requests, and the size of the data being transferred. It is a crucial tool for understanding the performance characteristics of your Redis setup and how it behaves under load.
The results are usually displayed at the end of the benchmark. You can benchmark different Redis functions and configurations with it.

UNDERSTANDING THE OUTPUT

The output of redis-benchmark typically includes the number of requests per second for each command tested, as well as the latency (time taken to process each request).
Higher requests per second and lower latency indicate better performance. It will show average latency but also latency at different percentile levels.

EXAMPLE USAGE

To benchmark SET and GET operations with 100 clients sending a total of 100000 requests: redis-benchmark -c 100 -n 100000 -t set,get

HISTORY

redis-benchmark was created as part of the Redis project to provide a standardized way to evaluate and compare the performance of Redis instances.
It has been continuously developed alongside Redis, with improvements in accuracy, functionality, and reporting over time.

SEE ALSO

Copied to clipboard