Rate This Document
Findability
Accuracy
Completeness
Readability

Running Test

After compiling and installing Redis, start the Redis server and use the redis-benchmark test tool provided by Redis to test the performance.

This section describes the command syntax and options of a common redis-benchmark command and provides a test example.

Syntax

redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests>] [-k <boolean>]

Description of Command Options

Table 1 Common redis-benchmark command options

Command Option

Description

-h <hostname>

Specifies the host name or IP address of the Redis server. The default value is 127.0.0.1.

-p <port>

Specifies the port number of the Redis server. The default value is 6379.

-s <socket>

Specifies the server socket. When this option is used, hostname and port are invalid.

-a <password>

Specifies the password of the Redis server.

-user <username>

Specifies the user name for connecting to the Redis server.

-c <clients>

Specifies the number of concurrent connections. The default value is 50.

-n <requests>

Specifies the number of requests to be sent. The default value is 100000.

-d <size>

Specifies the data size of SET/GET operations, in bytes. The default value is 3.

-dbnum <db>

Specifies the sequence number of a database. The default value is 0.

-threads <num>

Enables the multi-thread mode for clients and specifies the number of threads.

-cluster

Enables the cluster test mode.

-trac

Sends client tracing before the test is started.

-k <boolean>

Indicates whether the connection is persistent during the test. The value 1 indicates persistent connection, and 0 indicates non-persistent connection. The default value is 1.

-r <keyspacelen>

Configures the key of specified data. Use a random key for SET/GET/INCR, a random value for SADD, and a random member and score for ZADD.

-P <numreq>

Enables pipelining and configures the data volume of each request. The default value is 1.

-q

Indicates that intermediate data is not output.

-csv

Outputs the test result in CSV format.

-l

Uses the loop mode.

-t <tests>

Specifies the test command type, such as PING, SET, and GET. Separate multiple values with commas (,).

-I

Uses the idle mode. Just open idle connections and wait.

Example

  1. Start the Redis server.
    redis-server
  2. Start 10 redis-benchmark threads, create 1000 connections, and randomly send 10,000,000 set and get requests.
    redis-benchmark -h 127.0.0.1 -c 1000 -n 10000000 -r 10000000 -t set,get --threads 10

    When data of the string type is tested, if you do not insert data using the SET instruction in advance on the Redis server, the Redis server will return null data during the GET test. In this case, the size of the data packet is smaller than that of a data packet on which SET is performed first and then GET. This happens when data of other data types (such as list and zset) is tested.

    The test result consists of three parts: main parameter configuration, latency distribution, number of processed requests per second, and latency summary.

    Figure 1 Main parameter configuration example
    Figure 2 Latency distribution example
    Figure 3 Example of the number of processed requests per second and latency summary