Redis benchmark測試Redis效能

2021-08-22 12:16:12 字數 3659 閱讀 4988

redis-benchmark是官方自帶的redis效能測試工具,可以有效的測試redis服務的效能。

使用說明如下:

usage: redis-benchmark [-h ] [-p ] [-c ] [-n [-k ]

-h server hostname (default 127.0.0.1)

-p server port (default 6379)

-s server socket (overrides host and port)

-c number of parallel connections (default 50)

-n total number of requests (default 10000)

-d data size of set/get value in bytes (default 2)

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

-r use random keys for set/get/incr, random values for

sadd

using this option the benchmark will get/set keys

in the form mykey_rand:000000012456 instead of constant

keys, the argument determines the max

number of values for the random number. for

instance

if set to 10 only rand:000000000000 - rand:000000000009

range will be allowed.

-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 ones produced as output.

-i idle mode. just open n idle connections and wait.

測試命令事例:

1、redis-benchmark -h 192.168.1.201 -p 6379 -c 100 -n 100000

100個併發連線,100000個請求,檢測host為localhost 埠為6379的redis伺服器效能 

2、redis-benchmark -h 192.168.1.201 -p 6379 -q -d 100

測試訪問大小為100位元組的資料報的效能

3、redis-benchmark -t set,lpush -n 100000 -q

只測試某些操作的效能

4、redis-benchmark -n 100000 -q script load "redis.call('set','foo','bar')"

只測試某些數值訪問的效能

測試結果分析:

www@iz23s8agtagz:~$ redis-benchmark -h 121.41.88.209 -p 63789  -t lrange -c 10

*****= lpush (needed to benchmark lrange) *****=

10000 requests completed in 0.16seconds

10parallel clients

3bytes payload

keep alive: 1

100.00% <= 0milliseconds

62111.80requests per second

*****= lrange_100 (first 100 elements) *****=

10000 requests completed in 0.26seconds

10parallel clients

3bytes payload

keep alive: 1

100.00% <= 0milliseconds

39062.50requests per second

*****= lrange_300 (first 300 elements) *****=

10000 requests completed in 0.62seconds

10parallel clients

3bytes payload

keep alive: 1

100.00% <= 0milliseconds

16051.36requests per second

*****= lrange_500 (first 450 elements) *****=

10000 requests completed in 0.91seconds

10parallel clients

3bytes payload

keep alive: 1

100.00% <= 0milliseconds

10940.92requests per second

*****= lrange_600 (first 600 elements) *****=

10000 requests completed in 1.18seconds

10parallel clients

3bytes payload

keep alive: 1

99.35% <= 1milliseconds

99.88% <= 2milliseconds

99.91% <= 4milliseconds

100.00% <= 4milliseconds

8474.58 requests per second

測試結果2:

www@iz23s8agtagz:~$ redis-benchmark -h 121.41.88.209 -p 63789  -t lrange -c 10 -q

lpush (needed to benchmark lrange): 64102.56requests per second

lrange_100 (first 100 elements): 39370.08requests per second

lrange_300 (first 300 elements): 16694.49requests per second

lrange_500 (first 450 elements): 11001.10requests per second

lrange_600 (first 600 elements): 8319.47 requests per second

Redis benchmark使用總結

redis benchmark為redis效能測試工具。指令說明 usage redis benchmark h p c n k h server hostname default 127.0.0.1 p server port default 6379 s server socket overri...

redis benchmark 限流控制

由於自帶的redis benchmark不能按照設定的tps執行,因此增加tps控制功能。x t t tps 1 t x tps t 其中,x表示處理的請求數,t表示處理x筆請求花費的時間,t 表示需要等待的時間,tps表示設定的tps值利用redis benchmark中自帶的時間事件實現 int...

Redis benchmark測試Redis效能

引自 redis benchmark為redis效能測試工具。指令說明 usage redis benchmark h p c n k h server hostname default 127.0.0.1 p server port default 6379 s server socket ove...