redis-benchmark使用方法总结:包括各个指令的详细解释。
redis-3.0.4
1.redis-benchmark -help
hadoop@Master:~$ redis-benchmark -help Invalid option "-help" or option argument missing 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) //socket,覆盖host和port -a <password> Password for Redis Auth //密码 -c <clients> Number of parallel connections (default 50) //并行请求的客户端数量,默认50 -n <requests> Total number of requests (default 100000) //请求的总量,默认100000 -d <size> Data size of SET/GET value in bytes (default 2) //set或get的数据尺寸,单位是字节,默认是2 -dbnum <db> SELECT the specified db number (default 0) //选择指定的数据号 -k <boolean> 1=keep alive 0=reconnect (default 1) //布尔量,1代表保持活跃,0代表重连 -r <keyspacelen> Use random keys for SET/GET/INCR, random values for SADD //set/get/incr使用随机的keys,SADD使用随机值... Using this option the benchmark will expand the string __rand_int__ inside an argument with a 12 digits number in the specified range from 0 to keyspacelen-1. The substitution changes every time a command is executed. Default tests use this to hit random keys in the specified range. -P <numreq> Pipeline <numreq> requests. Default 1 (no pipeline). //管道请求,默认是1,没管道(并行?) -q Quiet. Just show query/sec values //安静,仅仅展示每秒的查询值 --csv Output in CSV format //输出按CSV格式 -l Loop. Run the tests forever -t <tests> Only run the comma separated list of tests. The test //仅仅运行tests names are the same as the ones produced as output. -I Idle mode. Just open N idle connections and wait. //闲置模型,进打开N个闲置链接且等待 Examples: Run the benchmark with the default configuration against 127.0.0.1:6379: $ redis-benchmark Use 20 parallel clients, for a total of 100k requests, against 192.168.1.1: $ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20 Fill 127.0.0.1:6379 with about 1 million keys only using the SET test: $ redis-benchmark -t set -n 1000000 -r 100000000 Benchmark 127.0.0.1:6379 for a few commands producing CSV output: $ redis-benchmark -t ping,set,get -n 100000 --csv Benchmark a specific command line: $ redis-benchmark -r 10000 -n 10000 eval 'return redis.call("ping")' 0 Fill a list with 10000 random elements: $ redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__ On user specified command lines __rand_int__ is replaced with a random integer with a range of values selected by the -r option.
自己看下就能明白意思。
下面简单抛下:
2.直接测试redis-benchmark:
hadoop@Master:~$ redis-benchmark ====== PING_INLINE ====== 100000 requests completed in 0.81 seconds //默认是100000,上面有,请求在0.81s内完成 50 parallel clients //50个客户端并行操作 3 bytes payload //每次写入3个字节的数据 keep alive: 1 //保持一个连接,一台服务器来处理这些请求 ??未验证是一个服务器还是一个实例?? 99.86% <= 1 milliseconds 99.97% <= 3 milliseconds 100.00% <= 3 milliseconds 123609.39 requests per second ====== PING_BULK ====== 100000 requests completed in 0.80 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.81% <= 1 milliseconds 99.88% <= 2 milliseconds 100.00% <= 2 milliseconds 124378.11 requests per second ====== SET ====== 100000 requests completed in 0.87 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.33% <= 1 milliseconds 99.95% <= 5 milliseconds 100.00% <= 5 milliseconds 115340.26 requests per second ====== GET ====== 100000 requests completed in 0.80 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.90% <= 2 milliseconds 99.95% <= 3 milliseconds 100.00% <= 3 milliseconds 124688.28 requests per second ====== INCR ====== 100000 requests completed in 0.79 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.85% <= 1 milliseconds 99.86% <= 2 milliseconds 99.95% <= 3 milliseconds 100.00% <= 3 milliseconds 126582.27 requests per second ====== LPUSH ====== 100000 requests completed in 0.79 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.90% <= 2 milliseconds 99.91% <= 3 milliseconds 99.95% <= 4 milliseconds 100.00% <= 4 milliseconds 126262.62 requests per second ====== LPOP ====== 100000 requests completed in 0.79 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.90% <= 1 milliseconds 99.95% <= 2 milliseconds 100.00% <= 2 milliseconds 126742.72 requests per second ====== SADD ====== 100000 requests completed in 0.79 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.90% <= 1 milliseconds 99.95% <= 2 milliseconds 100.00% <= 2 milliseconds 127388.53 requests per second ====== SPOP ====== 100000 requests completed in 0.79 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.90% <= 2 milliseconds 100.00% <= 2 milliseconds 126903.55 requests per second ====== LPUSH (needed to benchmark LRANGE) ====== 100000 requests completed in 0.79 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.87% <= 1 milliseconds 99.91% <= 2 milliseconds 99.92% <= 3 milliseconds 100.00% <= 3 milliseconds 126262.62 requests per second ====== LRANGE_100 (first 100 elements) ====== 100000 requests completed in 2.01 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.70% <= 1 milliseconds 99.80% <= 2 milliseconds 99.95% <= 3 milliseconds 100.00% <= 3 milliseconds 49800.80 requests per second ====== LRANGE_300 (first 300 elements) ====== 100000 requests completed in 5.39 seconds 50 parallel clients 3 bytes payload keep alive: 1 1.82% <= 1 milliseconds 98.70% <= 2 milliseconds 99.43% <= 3 milliseconds 99.75% <= 4 milliseconds 99.96% <= 5 milliseconds 100.00% <= 5 milliseconds 18556.32 requests per second ====== LRANGE_500 (first 450 elements) ====== 100000 requests completed in 7.63 seconds 50 parallel clients 3 bytes payload keep alive: 1 0.23% <= 1 milliseconds 59.65% <= 2 milliseconds 98.03% <= 3 milliseconds 99.05% <= 4 milliseconds 99.73% <= 5 milliseconds 99.94% <= 6 milliseconds 99.98% <= 7 milliseconds 100.00% <= 8 milliseconds 100.00% <= 8 milliseconds 13107.88 requests per second ====== LRANGE_600 (first 600 elements) ====== 100000 requests completed in 9.94 seconds 50 parallel clients 3 bytes payload keep alive: 1 0.12% <= 1 milliseconds 19.07% <= 2 milliseconds 85.39% <= 3 milliseconds 98.07% <= 4 milliseconds 99.00% <= 5 milliseconds 99.49% <= 6 milliseconds 99.76% <= 7 milliseconds 99.91% <= 8 milliseconds 99.97% <= 9 milliseconds 99.99% <= 10 milliseconds 100.00% <= 10 milliseconds 10059.35 requests per second ====== MSET (10 keys) ====== 100000 requests completed in 1.02 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.78% <= 1 milliseconds 99.90% <= 2 milliseconds 100.00% <= 2 milliseconds 97847.36 requests per second
这里-n从
-n <requests> Total number of requests (default 100000)
可以看出,代表是请求,总计的请求数量,默认是100000,这里改为了1000000;
-c从
-c <clients> Number of parallel connections (default 50)
可以看出代表并行链接的客户端数量,默认是50,这里改为了100.
hadoop@Master:~/cloud/redis-3.0.4$ redis-benchmark -n 1000000 -c 100 ====== PING_INLINE ====== 1000000 requests completed in 8.18 seconds 100 parallel clients 3 bytes payload keep alive: 1 99.74% <= 1 milliseconds 99.86% <= 2 milliseconds 99.97% <= 3 milliseconds 100.00% <= 4 milliseconds 100.00% <= 4 milliseconds 122279.28 requests per second ====== PING_BULK ====== 1000000 requests completed in 8.33 seconds 100 parallel clients 3 bytes payload keep alive: 1 99.64% <= 1 milliseconds 99.76% <= 2 milliseconds 99.93% <= 3 milliseconds 99.99% <= 4 milliseconds 100.00% <= 4 milliseconds 120062.42 requests per second ====== SET ====== 1000000 requests completed in 8.20 seconds 100 parallel clients 3 bytes payload keep alive: 1 99.66% <= 1 milliseconds 99.79% <= 2 milliseconds 99.93% <= 3 milliseconds 100.00% <= 4 milliseconds 100.00% <= 4 milliseconds 122010.73 requests per second ====== GET ====== 1000000 requests completed in 8.18 seconds 100 parallel clients 3 bytes payload keep alive: 1 99.74% <= 1 milliseconds 99.83% <= 2 milliseconds 99.96% <= 3 milliseconds 100.00% <= 3 milliseconds 122234.45 requests per second ====== INCR ====== 1000000 requests completed in 8.13 seconds 100 parallel clients 3 bytes payload keep alive: 1 99.71% <= 1 milliseconds 99.84% <= 2 milliseconds 99.94% <= 3 milliseconds 100.00% <= 3 milliseconds 123061.77 requests per second ====== LPUSH ====== 1000000 requests completed in 8.09 seconds 100 parallel clients 3 bytes payload keep alive: 1 99.67% <= 1 milliseconds 99.83% <= 2 milliseconds 99.96% <= 3 milliseconds 100.00% <= 4 milliseconds 100.00% <= 4 milliseconds 123609.39 requests per second ====== LPOP ====== 1000000 requests completed in 8.14 seconds 100 parallel clients 3 bytes payload keep alive: 1 99.54% <= 1 milliseconds 99.79% <= 2 milliseconds 99.93% <= 3 milliseconds 99.97% <= 4 milliseconds 99.98% <= 5 milliseconds 99.99% <= 6 milliseconds 99.99% <= 7 milliseconds 100.00% <= 7 milliseconds 122865.22 requests per second ====== SADD ====== 1000000 requests completed in 8.04 seconds 100 parallel clients 3 bytes payload keep alive: 1 99.72% <= 1 milliseconds 99.86% <= 2 milliseconds 99.97% <= 3 milliseconds 100.00% <= 3 milliseconds 124393.59 requests per second ====== SPOP ====== 1000000 requests completed in 8.09 seconds 100 parallel clients 3 bytes payload keep alive: 1 99.69% <= 1 milliseconds 99.85% <= 2 milliseconds 99.99% <= 3 milliseconds 100.00% <= 4 milliseconds 100.00% <= 4 milliseconds 123624.68 requests per second ====== LPUSH (needed to benchmark LRANGE) ====== 1000000 requests completed in 8.13 seconds 100 parallel clients 3 bytes payload keep alive: 1 99.47% <= 1 milliseconds 99.81% <= 2 milliseconds 99.94% <= 3 milliseconds 99.98% <= 4 milliseconds 99.99% <= 5 milliseconds 100.00% <= 5 milliseconds 123031.49 requests per second ====== LRANGE_100 (first 100 elements) ====== 1000000 requests completed in 20.18 seconds 100 parallel clients 3 bytes payload keep alive: 1 42.68% <= 1 milliseconds 99.34% <= 2 milliseconds 99.80% <= 3 milliseconds 99.95% <= 4 milliseconds 100.00% <= 4 milliseconds 49546.65 requests per second ====== LRANGE_300 (first 300 elements) ====== 1000000 requests completed in 54.01 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.01% <= 1 milliseconds 2.15% <= 2 milliseconds 75.25% <= 3 milliseconds 98.11% <= 4 milliseconds 99.04% <= 5 milliseconds 99.50% <= 6 milliseconds 99.76% <= 7 milliseconds 99.89% <= 8 milliseconds 99.95% <= 9 milliseconds 99.98% <= 10 milliseconds 100.00% <= 11 milliseconds 100.00% <= 12 milliseconds 100.00% <= 13 milliseconds 100.00% <= 13 milliseconds 18513.72 requests per second ====== LRANGE_500 (first 450 elements) ====== 1000000 requests completed in 75.73 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.00% <= 1 milliseconds 0.03% <= 2 milliseconds 11.64% <= 3 milliseconds 59.78% <= 4 milliseconds 98.00% <= 5 milliseconds 99.22% <= 6 milliseconds 99.60% <= 7 milliseconds 99.78% <= 8 milliseconds 99.87% <= 9 milliseconds 99.93% <= 10 milliseconds 99.97% <= 11 milliseconds 99.98% <= 12 milliseconds 99.99% <= 13 milliseconds 100.00% <= 14 milliseconds 100.00% <= 15 milliseconds 100.00% <= 15 milliseconds 13205.16 requests per second ====== LRANGE_600 (first 600 elements) ====== 1000000 requests completed in 98.43 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.00% <= 1 milliseconds 0.01% <= 2 milliseconds 0.17% <= 3 milliseconds 15.85% <= 4 milliseconds 53.14% <= 5 milliseconds 89.14% <= 6 milliseconds 99.06% <= 7 milliseconds 99.53% <= 8 milliseconds 99.75% <= 9 milliseconds 99.85% <= 10 milliseconds 99.91% <= 11 milliseconds 99.94% <= 12 milliseconds 99.96% <= 13 milliseconds 99.98% <= 14 milliseconds 99.99% <= 15 milliseconds 99.99% <= 16 milliseconds 100.00% <= 17 milliseconds 100.00% <= 17 milliseconds 10159.92 requests per second ====== MSET (10 keys) ====== 1000000 requests completed in 10.11 seconds 100 parallel clients 3 bytes payload keep alive: 1 83.03% <= 1 milliseconds 99.25% <= 2 milliseconds 99.88% <= 3 milliseconds 99.96% <= 4 milliseconds 99.98% <= 5 milliseconds 99.99% <= 6 milliseconds 100.00% <= 6 milliseconds 98872.84 requests per second
4.测试实例: redis-benchmark -t set -n 1000000 -r 100000000
Fill 127.0.0.1:6379 with about 1 million keys only using the SET test: 仅仅使用set测试,一百万请求
hadoop@Master:~/cloud/redis-3.0.4$ redis-benchmark -t set -n 1000000 -r 100000000 ====== SET ====== 1000000 requests completed in 8.29 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.42% <= 1 milliseconds 99.85% <= 2 milliseconds 99.96% <= 3 milliseconds 99.99% <= 4 milliseconds 100.00% <= 5 milliseconds 100.00% <= 5 milliseconds 120685.49 requests per second
测试ping,set,get,请求书为100000,输出格式为CSV
hadoop@Master:~/cloud/redis-3.0.4$ redis-benchmark -t ping,set,get -n 100000 --csv "PING_INLINE","123304.56" "PING_BULK","123609.39" "SET","81967.21" "GET","125470.52"
随机值在10000以内,请求数为10000,
hadoop@Master:~/cloud/redis-3.0.4$ redis-benchmark -r 10000 -n 10000 eval 'return redis.call("ping")' 0 ====== eval return redis.call("ping") 0 ====== 10000 requests completed in 0.12 seconds 50 parallel clients 3 bytes payload keep alive: 1 98.90% <= 1 milliseconds 100.00% <= 1 milliseconds 80000.00 requests per second
用10000个随机元素填充一个list,列表。随机数的值为10000以内
hadoop@Master:~/cloud/redis-3.0.4$ redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__ ====== lpush mylist __rand_int__ ====== 10000 requests completed in 0.18 seconds 50 parallel clients 3 bytes payload keep alive: 1 49.79% <= 1 milliseconds 98.90% <= 2 milliseconds 99.22% <= 4 milliseconds 99.48% <= 6 milliseconds 99.51% <= 8 milliseconds 99.54% <= 14 milliseconds 100.00% <= 14 milliseconds 55865.92 requests per second
hadoop@Master:~/cloud/redis-3.0.4$ redis-benchmark -q -d 100 PING_INLINE: 124533.01 requests per second PING_BULK: 124378.11 requests per second SET: 80775.45 requests per second GET: 123001.23 requests per second INCR: 126582.27 requests per second LPUSH: 125786.16 requests per second LPOP: 125000.00 requests per second SADD: 126262.62 requests per second SPOP: 127713.92 requests per second LPUSH (needed to benchmark LRANGE): 126582.27 requests per second LRANGE_100 (first 100 elements): 40241.45 requests per second LRANGE_300 (first 300 elements): 15167.60 requests per second LRANGE_500 (first 450 elements): 10256.41 requests per second LRANGE_600 (first 600 elements): 7227.00 requests per second MSET (10 keys): 92850.51 requests per second