Redis-benchmark是官方自帶的Redis性能測試工具,能夠有效的測試Redis服務的性能。redis
Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>] -h <hostname> Server hostname (default 127.0.0.1) -p <port> Server port (default 6379) -s <socket> Server socket (overrides host and port) -c <clients> Number of parallel connections (default 50) -n <requests> Total number of requests (default 10000) -d <size> Data size of SET/GET value in bytes (default 2) -k <boolean> 1=keep alive 0=reconnect (default 1) -r <keyspacelen> 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 <keyspacelen> 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 <numreq> Pipeline <numreq> requests. Default 1 (no pipeline). -q Quiet. Just show query/sec values --csv Output in CSV format -l Loop. Run the tests forever -t <tests> 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.
測試命令事例服務器
一、redis-benchmark -h 192.168.1.201 -p 6379 -c 100 -n 100000 100個併發鏈接,100000個請求,檢測host爲localhost 端口爲6379的redis服務器性能併發
二、redis-benchmark -h 192.168.1.201 -p 6379 -q -d 100
測試存取大小爲100字節的數據包的性能dom
三、redis-benchmark -t set,lpush -n 100000 -q 只測試某些操做的性能socket
四、redis-benchmark -n 100000 -q script load "redis.call('set','foo','bar')" 只測試某些數值存取的性能ide
./redis-benchmark -h 192.168.31.209 -p 6379 -c 1000 -n 100000 -k 1 script load "redis.call('get', 'community:220926914592768')" ====== script load redis.call('get', 'community:220926914592768') ====== 100000 requests completed in 1.78 seconds 1000 parallel clients 3 bytes payload keep alive: 1 0.00% <= 7 milliseconds 14.96% <= 8 milliseconds 33.49% <= 9 milliseconds 59.90% <= 10 milliseconds 96.10% <= 11 milliseconds 98.73% <= 12 milliseconds 99.01% <= 13 milliseconds 99.32% <= 14 milliseconds 99.49% <= 15 milliseconds 99.64% <= 16 milliseconds 99.86% <= 17 milliseconds 99.96% <= 18 milliseconds 100.00% <= 18 milliseconds 56242.97 requests per second