redis作壓測能夠用自帶的redis-benchmark工具,使用簡單,效果也比較不錯。html
linux下通常無需下載,windows下redis-benchmark壓力測試工具下載地址:http://www.daixiaorui.com/source/18.html(解壓後的redis-benchmark.exe)linux
壓測命令:redis-benchmark -h 127.0.0.1 -p 6379 -c 50 -n 10000redis
-c表示鏈接數windows
-n表示請求數工具
更多參數請輸入 --help 查看~性能
壓測須要一段時間,由於它須要依次壓測多個命令的結果,如:get、set、incr、lpush等等,因此咱們須要耐心等待,若是隻須要壓測某個命令,如:get,那麼能夠在以上的命令後加一個參數-t(紅色部分):測試
redis-benchmark -h 127.0.0.1 -p 6086 -c 50 -n 10000 -t getui
壓測結果:htm
[root@1234 ~]# redis-benchmark -h 127.0.0.1 -p 6086 -c 50 -n 10000 -t getelement
====== GET ======
10000 requests completed in 0.15 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.16% <= 1 milliseconds
100.00% <= 1 milliseconds
68027.21 requests per second
不帶-t的壓測結果以下:
[root@1234 ~]# redis-benchmark -h 127.0.0.1 -p 6086 -c 50 -n 10000
====== PING_INLINE ======
10000 requests completed in 0.15 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.35% <= 1 milliseconds
100.00% <= 1 milliseconds
67114.09 requests per second
====== PING_BULK ======
10000 requests completed in 0.15 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.38% <= 1 milliseconds
100.00% <= 1 milliseconds
66666.66 requests per second
====== SET ====== (處理set的性能)
10000 requests completed in 0.17 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.11% <= 1 milliseconds
99.51% <= 25 milliseconds
100.00% <= 25 milliseconds
57142.86 requests per second
====== GET ====== (處理get請求的性能)
10000 requests completed in 0.15 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.09% <= 1 milliseconds
99.51% <= 11 milliseconds
100.00% <= 12 milliseconds
66666.66 requests per second
====== INCR ======
10000 requests completed in 0.15 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.33% <= 1 milliseconds
100.00% <= 1 milliseconds
66666.66 requests per second
====== LPUSH ======
10000 requests completed in 0.16 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.20% <= 1 milliseconds
100.00% <= 1 milliseconds
64516.13 requests per second
====== LPOP ======
10000 requests completed in 0.16 seconds
50 parallel clients
3 bytes payload
keep alive: 1
98.56% <= 1 milliseconds
99.51% <= 14 milliseconds
100.00% <= 14 milliseconds
61349.69 requests per second
====== SADD ======
10000 requests completed in 0.15 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.36% <= 1 milliseconds
100.00% <= 1 milliseconds
67114.09 requests per second
====== SPOP ======
10000 requests completed in 0.14 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.32% <= 1 milliseconds
100.00% <= 1 milliseconds
69930.07 requests per second
====== LPUSH (needed to benchmark LRANGE) ======
10000 requests completed in 0.15 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.47% <= 1 milliseconds
100.00% <= 1 milliseconds
67567.57 requests per second
====== LRANGE_100 (first 100 elements) ======
10000 requests completed in 0.14 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.41% <= 1 milliseconds
100.00% <= 1 milliseconds
72992.70 requests per second
====== LRANGE_300 (first 300 elements) ======
10000 requests completed in 0.14 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.41% <= 1 milliseconds
100.00% <= 1 milliseconds
72463.77 requests per second
====== LRANGE_500 (first 450 elements) ======
10000 requests completed in 0.14 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.35% <= 1 milliseconds
100.00% <= 1 milliseconds
68965.52 requests per second
====== LRANGE_600 (first 600 elements) ======
10000 requests completed in 0.15 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.37% <= 1 milliseconds
100.00% <= 1 milliseconds
66225.17 requests per second
====== MSET (10 keys) ======
10000 requests completed in 0.17 seconds
50 parallel clients
3 bytes payload
keep alive: 1
94.94% <= 1 milliseconds
100.00% <= 1 milliseconds
58479.53 requests per second
這樣看起來很冗餘,若是咱們只想看最終的結果,能夠帶上參數-q,完整的命令以下:
redis-benchmark -h 127.0.0.1 -p 6086 -c 50 -n 10000 -q
顯示結果爲:
[root@1234 ~]# redis-benchmark -h 127.0.0.1 -p 6086 -c 50 -n 10000 -q
PING_INLINE: 66225.17 requests per second
PING_BULK: 65789.48 requests per second
SET: 66666.66 requests per second
GET: 69444.45 requests per second
INCR: 62893.08 requests per second
LPUSH: 65789.48 requests per second
LPOP: 68027.21 requests per second
SADD: 64935.07 requests per second
SPOP: 67114.09 requests per second
LPUSH (needed to benchmark LRANGE): 62893.08 requests per second
LRANGE_100 (first 100 elements): 69444.45 requests per second
LRANGE_300 (first 300 elements): 68965.52 requests per second
LRANGE_500 (first 450 elements): 68965.52 requests per second
LRANGE_600 (first 600 elements): 68965.52 requests per second
MSET (10 keys): 59171.60 requests per second
舒適提示:
壓測結果跟機器的性能有關,其中windows下壓測的結果要比在linux下差一大截。