如何使用 Redis-benchmark 对 Redis 进行性能测试

数据库NoSQL数据库技术服务知识库
前言

Redis-benchmark 是 Redis 官方自带的 Redis 性能测试工具,可以有效的测试 Redis 服务的性能。 本文将介绍如何使用 Redis-benchmark 对 Redis 进行性能测试。

详细信息
  • Redis-benchmark使用说明 Redis-benchmark参数的使用说明如下所示。
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       Pipelinerequests. 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.
  • 命令示例 Redis-benchmark 命令的使用示例如下所示。
  1. 测试使用 100 个并发连接、10000 个请求检测端口为 6379 的 Redis 服务器性能。
redis-benchmark -h <Redis实例连接地址> -p 6379 -c 100 -n 10000
  1. 测试获取大小为 100 字节的数据包的性能。
redis-benchmark -h <Redis实例连接地址> -p 6379 -q -d 100
  1. 仅测试部分操作的性能。
redis-benchmark -h <Redis实例连接地址> -t set,lpush -n 10000 -q
  1. 仅测试部分数据存取的性能。
redis-benchmark -h <Redis实例连接地址> -n 10000 -q script load "redis.call('set','foo','bar')"
52
0
0
0
相关产品
评论
未登录
看完啦,登录分享一下感受吧~
暂无评论