Redis-benchmark测试Redis性能
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Redis-benchmark测试Redis性能相关的知识,希望对你有一定的参考价值。
Redis-benchmark是官方自带的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.
测试命令事例:
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‘)"
只测试某些数值存取的性能
测试结果分析:
[email protected]:~$ 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: 1 100.00% <= 0 milliseconds 62111.80 requests per second ====== LRANGE_100 (first 100 elements) ====== 10000 requests completed in 0.26 seconds 10 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 39062.50 requests per second ====== LRANGE_300 (first 300 elements) ====== 10000 requests completed in 0.62 seconds 10 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 16051.36 requests per second ====== LRANGE_500 (first 450 elements) ====== 10000 requests completed in 0.91 seconds 10 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 10940.92 requests per second ====== LRANGE_600 (first 600 elements) ====== 10000 requests completed in 1.18 seconds 10 parallel clients 3 bytes payload keep alive: 1 99.35% <= 1 milliseconds 99.88% <= 2 milliseconds 99.91% <= 4 milliseconds 100.00% <= 4 milliseconds 8474.58 requests per second
测试结果2:
[email protected]:~$ redis-benchmark -h 121.41.88.209 -p 63789 -t lRange -c 10 -q LPUSH (needed to benchmark LRANGE): 64102.56 requests per second LRANGE_100 (first 100 elements): 39370.08 requests per second LRANGE_300 (first 300 elements): 16694.49 requests per second LRANGE_500 (first 450 elements): 11001.10 requests per second LRANGE_600 (first 600 elements): 8319.47 requests per second
以上是关于Redis-benchmark测试Redis性能的主要内容,如果未能解决你的问题,请参考以下文章