Getting Started with the redis-benchmark Tool: Generating Stress Test Data and Writing it to Redis

Preface

redis-benchmarkIt is a benchmark testing tool that comes with Redis. It can be used to stress test the performance of the redis target cluster and can also generate test data to facilitate testing.

Install redis-benchmark (Ubuntu system in this article)

Installation kit

sudo apt-get install redis-server
或者
apt install redis-tools

Test whether the installation is successful

redis-benchmark -h

Command usage

(1) Generate a set command with a specified byte size

./redis-benchmark -h 127.0.0.1 -p 10727 -t set -d 128 -n 10000000 -r 100000000 -c 200

The meaning of each option is explained below:

  • ./redis-benchmark: Execution command of Redis benchmark tool.
  • -h 127.0.0.1: The host name or IP address of the Redis server.
  • -p 10727: The port number that the Redis server listens to.
  • -t set: Redis commands used for testing. This refers to the SET command, which is used to write data to the Redis server.
  • -d 128: The size of the data written by the SET command, in bytes. Here it is 128 bytes.
  • -n 10000000: The total number of data written to the SET command when executing the test.
  • -r 100000000: The total number of random accesses to the data set while executing the test.
  • -c 200: The number of clients executing the SET command at the same time, that is, the number of concurrent clients.

This command will start the Redis benchmark tool, connect to the specified Redis server, and execute 10 million SET commands of size 128 bytes, using 200 concurrent clients. During the test, the data set was randomly accessed every 100,000 SET operations. The final output test results include the number of operations performed per second, average response time and other indicators.

(2) Generate a value of random size within the specified range

./redis-benchmark -h 127.0.0.1 -p 10727 -t set -d 512 -r 100000000 -n 10000000 -c 200

This command will execute the SET command 10 million times, using 200 concurrent clients, and randomly generate a value between 1 and 512 bytes each time the SET command is executed. During the test, the data set was randomly accessed every 100,000 SET operations. You can adjust -dthe options to specify the maximum size of the value according to the actual situation.

Guess you like

Origin blog.csdn.net/Mint6/article/details/130660529