1. 程式人生 > >【Redis】Redis-benchmark測試Redis效能

【Redis】Redis-benchmark測試Redis效能

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

  使用說明如下:

 1 Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>]
 2 
 3  -h <hostname>      Server hostname (default 127.0.0.1)
 4  -p <port>          Server port (default 6379)
5 -s <socket> Server socket (overrides host and port) 6 -c <clients> Number of parallel connections (default 50) 7 -n <requests> Total number of requests (default 10000) 8 -d <size> Data size of SET/GET value in bytes (default 2) 9 -k <boolean
> 1=keep alive 0=reconnect (default 1) 10 -r <keyspacelen> Use random keys for SET/GET/INCR, random values for SADD 11 Using this option the benchmark will get/set keys 12 in the form mykey_rand:000000012456 instead of constant 13 keys, the <keyspacelen> argument determines the max
14 number of values for the random number. For instance 15 if set to 10 only rand:000000000000 - rand:000000000009 16 range will be allowed. 17 -P <numreq> Pipeline <numreq> requests. Default 1 (no pipeline). 18 -q Quiet. Just show query/sec values 19 --csv Output in CSV format 20 -l Loop. Run the tests forever 21 -t <tests> Only run the comma-separated list of tests. The test 22 names are the same as the ones produced as output. 23 -I Idle mode. Just open N idle connections and wait.

測試命令事例

  1、redis-benchmark -h 127.0.0.1 -p 6379 -c 100 -n 100000 
  100個併發連線,100000個請求,檢測host為localhost 埠為6379的redis伺服器效能 

  2、redis-benchmark -h 127.0.0.1 -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')"

  只測試某些數值存取的效能

測試結果分析

  1 [[email protected]__D redis]# redis-benchmark -h 127.0.0.1 -p 6379 -c 100 -n 100000 
  2 ====== PING_INLINE ======
  3   100000 requests completed in 0.94 seconds
  4   100 parallel clients
  5   3 bytes payload
  6   keep alive: 1
  7 
  8 99.50% <= 1 milliseconds
  9 99.97% <= 2 milliseconds
 10 100.00% <= 2 milliseconds
 11 106951.88 requests per second
 12 
 13 ====== PING_BULK ======
 14   100000 requests completed in 0.89 seconds
 15   100 parallel clients
 16   3 bytes payload
 17   keep alive: 1
 18 
 19 99.43% <= 1 milliseconds
 20 99.98% <= 2 milliseconds
 21 100.00% <= 2 milliseconds
 22 111856.82 requests per second
 23 
 24 ====== SET ======
 25   100000 requests completed in 0.92 seconds
 26   100 parallel clients
 27   3 bytes payload
 28   keep alive: 1
 29 
 30 99.67% <= 1 milliseconds
 31 100.00% <= 2 milliseconds
 32 108459.87 requests per second
 33 
 34 ====== GET ======
 35   100000 requests completed in 0.91 seconds
 36   100 parallel clients
 37   3 bytes payload
 38   keep alive: 1
 39 
 40 99.60% <= 1 milliseconds
 41 100.00% <= 2 milliseconds
 42 100.00% <= 2 milliseconds
 43 109769.48 requests per second
 44 
 45 ====== INCR ======
 46   100000 requests completed in 0.92 seconds
 47   100 parallel clients
 48   3 bytes payload
 49   keep alive: 1
 50 
 51 99.64% <= 1 milliseconds
 52 100.00% <= 2 milliseconds
 53 100.00% <= 2 milliseconds
 54 109289.62 requests per second
 55 
 56 ====== LPUSH ======
 57   100000 requests completed in 0.92 seconds
 58   100 parallel clients
 59   3 bytes payload
 60   keep alive: 1
 61 
 62 99.71% <= 1 milliseconds
 63 100.00% <= 2 milliseconds
 64 100.00% <= 2 milliseconds
 65 109170.30 requests per second
 66 
 67 ====== RPUSH ======
 68   100000 requests completed in 0.92 seconds
 69   100 parallel clients
 70   3 bytes payload
 71   keep alive: 1
 72 
 73 99.64% <= 1 milliseconds
 74 99.99% <= 2 milliseconds
 75 100.00% <= 2 milliseconds
 76 108695.65 requests per second
 77 
 78 ====== LPOP ======
 79   100000 requests completed in 0.91 seconds
 80   100 parallel clients
 81   3 bytes payload
 82   keep alive: 1
 83 
 84 99.62% <= 1 milliseconds
 85 99.99% <= 2 milliseconds
 86 100.00% <= 2 milliseconds
 87 109529.02 requests per second
 88 
 89 ====== RPOP ======
 90   100000 requests completed in 0.91 seconds
 91   100 parallel clients
 92   3 bytes payload
 93   keep alive: 1
 94 
 95 99.74% <= 1 milliseconds
 96 99.99% <= 2 milliseconds
 97 100.00% <= 2 milliseconds
 98 109409.20 requests per second
 99 
100 ====== SADD ======
101   100000 requests completed in 0.92 seconds
102   100 parallel clients
103   3 bytes payload
104   keep alive: 1
105 
106 99.61% <= 1 milliseconds
107 99.99% <= 2 milliseconds
108 100.00% <= 2 milliseconds
109 109051.26 requests per second
110 
111 ====== HSET ======
112   100000 requests completed in 0.93 seconds
113   100 parallel clients
114   3 bytes payload
115   keep alive: 1
116 
117 99.32% <= 1 milliseconds
118 99.98% <= 2 milliseconds
119 100.00% <= 2 milliseconds
120 107642.62 requests per second
121 
122 ====== SPOP ======
123   100000 requests completed in 0.90 seconds
124   100 parallel clients
125   3 bytes payload
126   keep alive: 1
127 
128 99.76% <= 1 milliseconds
129 100.00% <= 1 milliseconds
130 110741.97 requests per second
131 
132 ====== LPUSH (needed to benchmark LRANGE) ======
133   100000 requests completed in 0.92 seconds
134   100 parallel clients
135   3 bytes payload
136   keep alive: 1
137 
138 99.69% <= 1 milliseconds
139 99.99% <= 2 milliseconds
140 100.00% <= 2 milliseconds
141 108577.63 requests per second
142 
143 ====== LRANGE_100 (first 100 elements) ======
144   100000 requests completed in 0.93 seconds
145   100 parallel clients
146   3 bytes payload
147   keep alive: 1
148 
149 99.77% <= 1 milliseconds
150 100.00% <= 1 milliseconds
151 108108.11 requests per second
152 
153 ====== LRANGE_300 (first 300 elements) ======
154   100000 requests completed in 0.93 seconds
155   100 parallel clients
156   3 bytes payload
157   keep alive: 1
158 
159 99.52% <= 1 milliseconds
160 100.00% <= 2 milliseconds
161 100.00% <= 2 milliseconds
162 107296.14 requests per second
163 
164 ====== LRANGE_500 (first 450 elements) ======
165   100000 requests completed in 0.94 seconds
166   100 parallel clients
167   3 bytes payload
168   keep alive: 1
169 
170 99.64% <= 1 milliseconds
171 99.99% <= 2 milliseconds
172 100.00% <= 2 milliseconds
173 106723.59 requests per second
174 
175 ====== LRANGE_600 (first 600 elements) ======
176   100000 requests completed in 0.92 seconds
177   100 parallel clients
178   3 bytes payload
179   keep alive: 1
180 
181 99.73% <= 1 milliseconds
182 100.00% <= 2 milliseconds
183 108225.10 requests per second
184 
185 ====== MSET (10 keys) ======
186   100000 requests completed in 1.06 seconds
187   100 parallel clients
188   3 bytes payload
189   keep alive: 1
190 
191 91.36% <= 1 milliseconds
192 99.97% <= 2 milliseconds
193 100.00% <= 2 milliseconds
194 94517.96 requests per second

 

 

 1 [[email protected]__D redis]# redis-benchmark -h 127.0.0.1 -p 6379 -q -d 100
 2 PING_INLINE: 113122.17 requests per second                                                                 
 3 PING_BULK: 117785.63 requests per second
 4 SET: 114285.71 requests per second
 5 GET: 116144.02 requests per second
 6 INCR: 116144.02 requests per second
 7 LPUSH: 113895.21 requests per second
 8 RPUSH: 113507.38 requests per second
 9 LPOP: 116550.12 requests per second
10 RPOP: 116279.07 requests per second
11 SADD: 115740.73 requests per second
12 HSET: 112866.82 requests per second
13 SPOP: 116279.07 requests per second
14 LPUSH (needed to benchmark LRANGE): 113636.37 requests per second
15 LRANGE_100 (first 100 elements): 114025.09 requests per second
16 LRANGE_300 (first 300 elements): 113895.21 requests per second
17 LRANGE_500 (first 450 elements): 113507.38 requests per second
18 LRANGE_600 (first 600 elements): 114155.25 requests per second
19 MSET (10 keys): 93023.25 requests per second