本文共 3024 字,大约阅读时间需要 10 分钟。
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.16 seconds 10 parallel clients 3 bytes payload keep alive: 1100.00% <= 0 milliseconds62111.80 requests per second====== LRANGE_100 (first 100 elements) ====== 10000 requests completed in 0.26 seconds 10 parallel clients 3 bytes payload keep alive: 1100.00% <= 0 milliseconds39062.50 requests per second====== LRANGE_300 (first 300 elements) ====== 10000 requests completed in 0.62 seconds 10 parallel clients 3 bytes payload keep alive: 1100.00% <= 0 milliseconds16051.36 requests per second====== LRANGE_500 (first 450 elements) ====== 10000 requests completed in 0.91 seconds 10 parallel clients 3 bytes payload keep alive: 1100.00% <= 0 milliseconds10940.92 requests per second====== LRANGE_600 (first 600 elements) ====== 10000 requests completed in 1.18 seconds 10 parallel clients 3 bytes payload keep alive: 199.35% <= 1 milliseconds99.88% <= 2 milliseconds99.91% <= 4 milliseconds100.00% <= 4 milliseconds8474.58 requests per second
测试结果2:
www@iZ23s8agtagZ:~$ redis-benchmark -h 121.41.88.209 -p 63789 -t lRange -c 10 -qLPUSH (needed to benchmark LRANGE): 64102.56 requests per secondLRANGE_100 (first 100 elements): 39370.08 requests per secondLRANGE_300 (first 300 elements): 16694.49 requests per secondLRANGE_500 (first 450 elements): 11001.10 requests per secondLRANGE_600 (first 600 elements): 8319.47 requests per second
转载地址:http://wuana.baihongyu.com/