Redis 压力测试--redis-benchmark

redis-benchmark使用参数介绍

Redis 自带了一个叫 redis-benchmark 的工具来模拟 N 个客户端同时发出 M 个请求。 (类似于 Apache ab 程序)。你可以使用 redis-benchmark -h 来查看基准参数。

redis 性能测试工具可选参数如下所示:

 

 

压测示例

压测需要一段时间,因为它需要依次压测多个命令的结果,如:get、set、incr、lpush等等,所以我们需要耐心等待,如果只需要压测某个命令,如:set,那么可以在以上的命令后加一个参数-t:

redis-benchmark -h 127.0.0.1 -p 6379 -n 100000 -c 50 -t set

====== SET ======
  100000 requests completed in 0.40 seconds           ## 0.4秒处理了100000个请求
  50 parallel clients                                 ## 50个并发
  3 bytes payload                                     ## 每次存取3 byte
  keep alive: 1
  host configuration "save": 3600 1 300 100 60 10000
  host configuration "appendonly": no
  multi-thread: no

22.96% <= 0.1 milliseconds
99.96% <= 0.2 milliseconds
100.00% <= 0.2 milliseconds
253164.55 requests per second

这样看起来数据很多,如果我们只想看最终的结果,可以带上参数-q,完整的命令如下:

示例2:

redis-benchmark -h 127.0.0.1 -p 6379 -n 100000 -c 50 -q

PING_INLINE: 218818.39 requests per second
PING_BULK: 250000.00 requests per second
SET: 251256.28 requests per second
GET: 250626.58 requests per second
INCR: 250626.58 requests per second
LPUSH: 252525.25 requests per second
RPUSH: 252525.25 requests per second
LPOP: 251889.16 requests per second
RPOP: 251889.16 requests per second
SADD: 253164.55 requests per second
HSET: 255754.47 requests per second
SPOP: 252525.25 requests per second
ZADD: 256410.27 requests per second
ZPOPMIN: 253164.55 requests per second
LPUSH (needed to benchmark LRANGE): 255102.05 requests per second
LRANGE_100 (first 100 elements): 102354.15 requests per second
LRANGE_300 (first 300 elements): 38431.98 requests per second
LRANGE_500 (first 450 elements): 26983.27 requests per second
LRANGE_600 (first 600 elements): 20721.09 requests per second
MSET (10 keys): 210970.47 requests per second

 

posted @ 2023-02-11 16:57  zhihua  阅读(686)  评论(0编辑  收藏  举报