中国站
帮助中心 > 数据库 > 云数据库Redis > 常见问题 > Redis的性能测试方法

Redis的性能测试方法

概述

Redis-benchmark是Redis官方自带的Redis性能测试工具,可以有效的测试Redis服务的性能,本文主要介绍相关信息。

详细信息

Redis-benchmark使用说明

Redis-benchmark参数的使用说明如下所示。

  1. Usage: redis-benchmark [-h] [-p] [-c] [-n[-k]
  2. -h Server hostname (default 127.0.0.1)
  3. -p Server port (default 6379)
  4. -s Server socket (overrides host and port)
  5. -c Number of parallel connections (default 50)
  6. -n Total number of requests (default 10000)
  7. -d Data size of SET/GET value in bytes (default 2)
  8. -k 1=keep alive 0=reconnect (default 1)
  9. -r Use random keys for SET/GET/INCR, random values for SADD
  10. Using this option the benchmark will get/set keys
  11. in the form mykey_rand:000000012456 instead of constant
  12. keys, the argument determines the max
  13. number of values for the random number. For instance
  14. if set to 10 only rand:000000000000 - rand:000000000009
  15. range will be allowed.
  16. -P Pipelinerequests. Default 1 (no pipeline).
  17. -q Quiet. Just show query/sec values
  18. --csv Output in CSV format
  19. -l Loop. Run the tests forever
  20. -t Only run the comma-separated list of tests. The test
  21. names are the same as the ones produced as output.
  22. -I Idle mode. Just open N idle connections and wait.

命令示例

Redis-benchmark命令的使用示例如下所示。

  • 如下命令所示,使用100个并发连接、100000个请求检测端口为6379的Redis服务器性能。
    1. redis-benchmark -h 172.xxx.xxx.101 -p 6379 -c 100 -n 100000
  • 如下命令所示,测试获取大小为100字节的数据包的性能
    1. redis-benchmark -h 172.xxx.xxx.101 -p 6379 -q -d 100
  • 如下命令所示,只测试部分操作的性能。
    1. redis-benchmark -t set,lpush -n 100000 -q
  • 如下命令所示,只测试部分数值存取的性能。
    1. redis-benchmark -n 100000 -q script load "redis.call('set','foo','bar')"