Redis性能测试Redis-benchmark
Posted 逆水行舟,不进则退
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Redis性能测试Redis-benchmark相关的知识,希望对你有一定的参考价值。
Redis-benchmark是官方自带的Redis性能测试工具
测试Redis在你的系统及你的配置下的读写性能
redis-benchmark可以模拟N个机器,同时发送M个请求
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.
eg:
100个并发连接,1000000个请求,检测host为localhost 端口为6379的redis服务器性能
redis-benchmark.exe -h 127.0.0.1 -p 6379 -c 100 -n 1000
====== PING_INLINE ====== 1000 requests completed in 0.07 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 22.00% <= 2 milliseconds 24.90% <= 3 milliseconds 75.90% <= 4 milliseconds 89.70% <= 11 milliseconds 89.80% <= 12 milliseconds 90.00% <= 13 milliseconds 90.10% <= 23 milliseconds 90.20% <= 24 milliseconds 90.40% <= 25 milliseconds 90.50% <= 32 milliseconds 96.20% <= 33 milliseconds 100.00% <= 33 milliseconds 14705.88 requests per second ====== PING_BULK ====== 1000 requests completed in 0.03 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 0.20% <= 2 milliseconds 79.20% <= 3 milliseconds 89.40% <= 4 milliseconds 100.00% <= 4 milliseconds 31250.00 requests per second ====== SET ====== 1000 requests completed in 0.03 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 8.20% <= 2 milliseconds 91.60% <= 3 milliseconds 100.00% <= 3 milliseconds 34482.76 requests per second ====== GET ====== 1000 requests completed in 0.04 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 30.40% <= 2 milliseconds 58.30% <= 3 milliseconds 66.10% <= 4 milliseconds 87.50% <= 5 milliseconds 99.90% <= 6 milliseconds 100.00% <= 6 milliseconds 27777.78 requests per second ====== INCR ====== 1000 requests completed in 0.04 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 23.60% <= 2 milliseconds 27.90% <= 3 milliseconds 75.20% <= 4 milliseconds 99.70% <= 5 milliseconds 100.00% <= 5 milliseconds 26315.79 requests per second ====== LPUSH ====== 1000 requests completed in 0.03 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 2 milliseconds 74.70% <= 3 milliseconds 83.40% <= 4 milliseconds 93.20% <= 5 milliseconds 100.00% <= 5 milliseconds 29411.76 requests per second ====== LPOP ====== 1000 requests completed in 0.01 seconds 100 parallel clients 3 bytes payload keep alive: 1 2.50% <= 1 milliseconds 100.00% <= 1 milliseconds 76923.08 requests per second ====== SADD ====== 1000 requests completed in 0.01 seconds 100 parallel clients 3 bytes payload keep alive: 1 1.90% <= 1 milliseconds 100.00% <= 1 milliseconds 76923.08 requests per second ====== SPOP ====== 1000 requests completed in 0.03 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 1.10% <= 2 milliseconds 99.70% <= 3 milliseconds 100.00% <= 3 milliseconds 33333.34 requests per second ====== LPUSH (needed to benchmark LRANGE) ====== 1000 requests completed in 0.03 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 66.80% <= 2 milliseconds 69.70% <= 3 milliseconds 77.00% <= 4 milliseconds 91.20% <= 5 milliseconds 99.10% <= 6 milliseconds 100.00% <= 6 milliseconds 32258.06 requests per second ====== LRANGE_100 (first 100 elements) ====== 1000 requests completed in 0.05 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 37.70% <= 2 milliseconds 90.10% <= 4 milliseconds 93.70% <= 5 milliseconds 99.60% <= 6 milliseconds 100.00% <= 6 milliseconds 20000.00 requests per second ====== LRANGE_300 (first 300 elements) ====== 1000 requests completed in 0.08 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 2 milliseconds 33.70% <= 3 milliseconds 69.80% <= 4 milliseconds 74.70% <= 5 milliseconds 80.40% <= 6 milliseconds 87.70% <= 7 milliseconds 90.20% <= 8 milliseconds 93.10% <= 9 milliseconds 96.70% <= 10 milliseconds 98.40% <= 11 milliseconds 99.80% <= 12 milliseconds 100.00% <= 12 milliseconds 12345.68 requests per second ====== LRANGE_500 (first 450 elements) ====== 1000 requests completed in 0.10 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 2 milliseconds 1.00% <= 3 milliseconds 30.10% <= 4 milliseconds 72.40% <= 5 milliseconds 80.40% <= 6 milliseconds 84.90% <= 7 milliseconds 88.50% <= 8 milliseconds 90.70% <= 9 milliseconds 92.70% <= 10 milliseconds 95.10% <= 11 milliseconds 96.60% <= 12 milliseconds 97.80% <= 13 milliseconds 98.80% <= 14 milliseconds 100.00% <= 14 milliseconds 10101.01 requests per second ====== LRANGE_600 (first 600 elements) ====== 1000 requests completed in 0.14 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 3 milliseconds 3.20% <= 4 milliseconds 31.60% <= 5 milliseconds 58.90% <= 6 milliseconds 78.60% <= 7 milliseconds 80.70% <= 8 milliseconds 82.30% <= 9 milliseconds 84.20% <= 10 milliseconds 86.30% <= 11 milliseconds 89.00% <= 12 milliseconds 89.30% <= 13 milliseconds 89.90% <= 14 milliseconds 90.40% <= 15 milliseconds 90.80% <= 16 milliseconds 91.10% <= 17 milliseconds 91.90% <= 18 milliseconds 92.40% <= 19 milliseconds 93.10% <= 20 milliseconds 93.80% <= 21 milliseconds 95.10% <= 22 milliseconds 96.90% <= 23 milliseconds 97.70% <= 24 milliseconds 98.40% <= 25 milliseconds 99.10% <= 26 milliseconds 99.90% <= 27 milliseconds 100.00% <= 27 milliseconds 7299.27 requests per second ====== MSET (10 keys) ====== 1000 requests completed in 0.02 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.70% <= 1 milliseconds 93.80% <= 2 milliseconds 99.40% <= 3 milliseconds 100.00% <= 3 milliseconds 52631.58 requests per second
只显示每秒钟能处理多少请求数结果
redis-benchmark.exe -h 127.0.0.1 -p 6379 -q
PING_INLINE: 87873.46 requests per second PING_BULK: 90009.01 requests per second SET: 81037.28 requests per second GET: 91324.20 requests per second INCR: 89605.73 requests per second LPUSH: 80256.82 requests per second LPOP: 90826.52 requests per second SADD: 89525.52 requests per second SPOP: 91996.32 requests per second LPUSH (needed to benchmark LRANGE): 90090.09 requests per second LRANGE_100 (first 100 elements): 34638.03 requests per second LRANGE_300 (first 300 elements): 17099.86 requests per second LRANGE_500 (first 450 elements): 12238.41 requests per second LRANGE_600 (first 600 elements): 9712.51 requests per second MSET (10 keys): 56657.22 requests per second
显示详细资料的方式
redis-benchmark -h 127.0.0.1 -p 6609 -n 1000
====== PING_INLINE ====== 1000 requests completed in 0.02 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 1 milliseconds 62500.00 requests per second ====== PING_BULK ====== 1000 requests completed in 0.01 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 76923.08 requests per second ====== SET ====== 1000 requests completed in 0.01 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 83333.34 requests per second ====== GET ====== 1000 requests completed in 0.01 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 76923.08 requests per second ====== INCR ====== 1000 requests completed in 0.01 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 83333.34 requests per second ====== LPUSH ====== 1000 requests completed in 0.01 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 76923.08 requests per second ====== LPOP ====== 1000 requests completed in 0.01 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 76923.08 requests per second ====== SADD ====== 1000 requests completed in 0.01 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 83333.34 requests per second ====== SPOP ====== 1000 requests completed in 0.01 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 83333.34 requests per second ====== LPUSH (needed to benchmark LRANGE) ====== 1000 requests completed in 0.01 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 83333.34 requests per second ====== LRANGE_100 (first 100 elements) ====== 1000 requests completed in 0.03 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.00% <= 1 milliseconds 100.00% <= 1 milliseconds 34482.76 requests per second ====== LRANGE_300 (first 300 elements) ====== 1000 requests completed in 0.06 seconds 50 parallel clients 3 bytes payload keep alive: 1 1.40% <= 1 milliseconds 97.70% <= 2 milliseconds 100.00% <= 2 milliseconds 16949.15 requests per second ====== LRANGE_500 (first 450 elements) ====== 1000 requests completed in 0.08 seconds 50 parallel clients 3 bytes payload keep alive: 1 1.10% <= 1 milliseconds 44.00% <= 2 milliseconds 98.40% <= 3 milliseconds 100.00% <= 3 milliseconds 12195.12 requests per second ====== LRANGE_600 (first 600 elements) ====== 1000 requests completed in 0.10 seconds 50 parallel clients 3 bytes payload keep alive: 1 0.80% <= 1 milliseconds 7.10% <= 2 milliseconds 86.80% <= 3 milliseconds 97.90% <= 4 milliseconds 100.00% <= 4 milliseconds 9803.92 requests per second ====== MSET (10 keys) ====== 1000 requests completed in 0.02 seconds 50 parallel clients 3 bytes payload keep alive: 1 95.60% <= 1 milliseconds 100.00% <= 1 milliseconds 58823.53 requests per second
以上是关于Redis性能测试Redis-benchmark的主要内容,如果未能解决你的问题,请参考以下文章