Twemproxy和Redis性能壓力測試

性能測試html

Redis自帶了一個叫 redis-benchmark的工具來模擬N個客戶端同時發出M個請求,(相似於Apache ab程序),你能夠使用redis-benchmark -h來查看基準參數。linux

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

-h       #指定服務器名稱(default 127.0.0.1);
-p           #指定服務器端口(default 6379);
-s         #指定服務器Socket(overrides host and port);
-a       #指定Redis密碼;
-c        #指定並行客戶端數量 (default 50);
-n       #指定總的請求數量(default 100000);
-d           #指定SET/GET一次數據大小 (default 2 Bytes);
-dbnum         #選擇指定的數據庫(default 0);
-k        #保持一個鏈接,一臺服務器來處理這些請求 (default 1);
-r    #設置隨機Key;
-P         #Pipeline  requests. Default 1 (no pipeline).
-q                 #顯示每秒鐘能處理多少請求數結果;
--csv              #輸出爲CSV格式;
-l                 #Loop. Run the tests forever.
-I                 #Idle mode. Just open N idle connections and wait.

這裏用redis自帶的benchmark工具測試,因爲twemproxy不支持ping命令,因此對於twemproxy只測試set, get, incr, lpush, lpop, sadd, spop, lpush, lrange_100, lrange_300, lrange_500, lrange_600,mset命令。redis

Redis單實例簡單測試數據庫

1)客戶端分別爲1/1000/5000,總請求數爲100000,Key大小爲1k,針對set/get命令測試QPS和完成時間(服務器:CPU 64核,內存 64G)緩存

# redis-benchmark -h 0.0.0.0 -p 6500 -c 1 -t set,get -d 1000
====== SET ======
 100000 requests completed in 2.65 seconds    #完成時間
 1 parallel clients
 1000 bytes payload
 keep alive: 1

100.00% < = 0 milliseconds
37764.35 requests per second                  #每秒請求數

====== GET ======
 100000 requests completed in 1.70 seconds
 1 parallel clients
 1000 bytes payload
 keep alive: 1

100.00% <= 0 milliseconds
58962.27 requests per second
# redis-benchmark -h 0.0.0.0 -p 6500 -c 1000 -t set,get -d 1000
====== SET ======
 100000 requests completed in 0.75 seconds
 1000 parallel clients
 1000 bytes payload
 keep alive: 1

0.00% < = 4 milliseconds
....................
100.00% <= 14 milliseconds
132450.33 requests per second

====== GET ======
 100000 requests completed in 0.78 seconds
 1000 parallel clients
 1000 bytes payload
 keep alive: 1

0.00% <= 3 milliseconds
..................
100.00% <= 8 milliseconds
128205.13 requests per second
# redis-benchmark -h 0.0.0.0 -p 6500 -c 5000 -t set,get -d 1000
====== SET ======
  100000 requests completed in 1.18 seconds
  5000 parallel clients
  1000 bytes payload
  keep alive: 1

0.00% < = 28 milliseconds
..........................
100.00% <= 105 milliseconds
84817.64 requests per second

====== GET ======
  100000 requests completed in 1.24 seconds
  5000 parallel clients
  1000 bytes payload
  keep alive: 1

0.00% <= 35 milliseconds
.......................
100.00% <= 55 milliseconds
80580.17 requests per second

下面提供一個CPU 8核,內存8G的壓測結果。服務器

root@shd-ops-mng1:~ # redis-benchmark -h 0.0.0.0 -p 6380 -c 1 -t set,get -d 1000
====== SET ======
  100000 requests completed in 6.50 seconds
  1 parallel clients
  1000 bytes payload
  keep alive: 1

98.95% < = 1 milliseconds
...................
100.00% <= 6 milliseconds
15379.88 requests per second

====== GET ======
  100000 requests completed in 6.68 seconds
  1 parallel clients
  1000 bytes payload
  keep alive: 1

98.91% <= 1 milliseconds
..................
100.00% <= 4 milliseconds
14965.58 requests per second
# redis-benchmark -h 0.0.0.0 -p 6380 -c 1000 -t set,get -d 1000
====== SET ======
  100000 requests completed in 0.96 seconds
  1000 parallel clients
  1000 bytes payload
  keep alive: 1

0.00% < = 4 milliseconds
....................
103734.44 requests per second

====== GET ======
  100000 requests completed in 1.00 seconds
  1000 parallel clients
  1000 bytes payload
  keep alive: 1

0.00% <= 3 milliseconds
...................
100.00% <= 15 milliseconds
100300.91 requests per second

默認狀況下面,基準測試使用單一的key。在一個基於內存的數據庫裏, 單一key測試和真實狀況下面不會有巨大變化。固然,使用一個大的key範圍空間, 能夠模擬現實狀況下面的緩存不命中狀況。ide

這時候咱們能夠使用-r命令。好比,假設咱們想設置10萬隨機key連續SET 100萬次,鏈接客戶端分別爲1/5/1000,咱們能夠使用下列的命令:工具

# redis-benchmark -h 0.0.0.0 -p 6500 -c 1 -r 100000 -q 1000000 -t set -d 1000 -q
1000000 -t set -d 1000 -q: 63051.70 requests per second

# redis-benchmark -h 0.0.0.0 -p 6500 -c 1000 -r 100000 -q 1000000 -t set -d 1000 -q
1000000 -t set -d 1000 -q: 94966.77 requests per second

# redis-benchmark -h 0.0.0.0 -p 6500 -c 5000 -r 100000 -q 1000000 -t set -d 1000 -q
1000000 -t set -d 1000 -q: 83542.19 requests per second

測試twemproxyoop

# redis-benchmark -h 0.0.0.0 -p 36379 -c 1 -t set,get -d 1000 
====== SET ======
  10000 requests completed in 1.08 seconds
  1 parallel clients
  1000 bytes payload
  keep alive: 1

100.00% < = 0 milliseconds
9267.84 requests per second

====== GET ======
  10000 requests completed in 1.08 seconds
  1 parallel clients
  1000 bytes payload
  keep alive: 1

100.00% <= 0 milliseconds
9293.68 requests per second
# redis-benchmark -h 0.0.0.0 -p 36379 -c 1000 -t set,get -d 1000 
====== SET ======
  10000 requests completed in 0.18 seconds
  1000 parallel clients
  1000 bytes payload
  keep alive: 1

0.01% < = 3 milliseconds
................
100.00% <= 20 milliseconds
55555.55 requests per second

====== GET ======
  10000 requests completed in 0.21 seconds
  1000 parallel clients
  1000 bytes payload
  keep alive: 1

0.01% <= 5 milliseconds
..............
100.00% <= 23 milliseconds
47393.37 requests per second
# redis-benchmark -h 0.0.0.0 -p 36379 -c 5000 -t set,get -d 1000 
====== SET ======
  10000 requests completed in 0.28 seconds
  5000 parallel clients
  1000 bytes payload
  keep alive: 1

0.01% < = 28 milliseconds
.......................
100.00% <= 87 milliseconds
35587.19 requests per second

====== GET ======
  10000 requests completed in 0.29 seconds
  5000 parallel clients
  1000 bytes payload
  keep alive: 1

0.01% <= 33 milliseconds
....................
100.00% <= 85 milliseconds
34364.26 requests per second

原文來自: https://www.linuxprobe.com/twemproxy-redis-test.html性能

相關文章
相關標籤/搜索