你万万想不到,Redis性能测试还能这样做

156 篇文章 0 订阅
92 篇文章 0 订阅
本文通过详述Redis自带的redis-benchmark工具,展示了如何进行单并发和多并发测试。测试结果显示,服务器配置差异显著影响Redis的性能,如CPU、内存使用和HZ设置。在32G内存服务器上,当Redis占用达到7G时,QPS从20W+急剧下降到3W+。
摘要由CSDN通过智能技术生成

在这里插入图片描述

01 服务器环境

在这里插入图片描述
Redis之redis-benchmark

redis 提供了 redis-benchmark 工具便于我们做性能测试,可以使用 redis-benchmark- h 查看参数。

在这里插入图片描述

01 Docker Redis测试

单并发测试

测试命令:

./redis-benchmark -c 1 -n 20000 -d 30720 -t set,get

测试结果每秒是 8000+的QPS

多并发测试

====== SET ======

  20000 requests completed in 1.06 seconds
  10 parallel clients
  30720 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
18903.59 requests per second
====== GET ======
  20000 requests completed in 1.30 seconds
  10 parallel clients
  30720 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
15360.98 requests per second

测试 -P 命令

====== SET ======
  20007 requests completed in 0.47 seconds
  50 parallel clients
  30720 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
42933.48 requests per second
====== GET ======
  20002 requests completed in 0.44 seconds
  50 parallel clients
  30720 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
45253.39 requests per second

02 redis6 安装版测试

单并发测试

====== SET ======

  200000 requests completed in 20.20 seconds
  1 parallel clients  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
9900.01 requests per second
====== GET ======
  200000 requests completed in 20.01 seconds
  1 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
9995.50 requests per second

多并发测试

====== SET ======
  200000 requests completed in 3.00 seconds
  10 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
66622.25 requests per second
====== GET ======
  200000 requests completed in 3.02 seconds
  10 parallel clients
  3 bytes payload
  keep alive:1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
66137.57 requests per second

03 -P 测试

单并发测试

====== SET ======

  200000 requests completed in 2.20 seconds
  1 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no  
multi-thread: no
90991.81 requests per second
====== GET ======
  200000 requests completed in 2.15 seconds
  1 parallel clients  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no  
multi-thread: no
92980.01 requests per second

多并发测试

====== SET ======

  200010 requests completed in 0.42 seconds
  10 parallel clients  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
480793.25 requests per second
====== GET ======
  200000 requests completed in 0.34 seconds
  10 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
586510.25 requests per second

02 换服务器测试

在这里插入图片描述

01 Docker Redis

单并发测试

====== SET ======

  20000 requests completed in 1.22 seconds
  1 parallel clients
  30720 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no  
multi-thread: no
16420.36 requests per second
====== GET ======

  20000 requests completed in 1.42 seconds
  1 parallel clients  30720 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
14094.43 requests per second

多并发测试

====== SET ======
  20000 requests completed in 0.66 seconds
  10 parallel clients
  30720 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
30395.14 requests per second
====== GET ======
  20000 requests completed in 0.81 seconds
  10 parallel clients
  30720 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no  
multi-thread: no
24721.88 requests per second

02 -P 测试

单并发测试

====== SET ======
  20000 requests completed in 0.59 seconds
  1 parallel clients
  30720 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
33726.81 requests per second
====== GET ======
  20000 requests completed in 0.50 seconds
  1 parallel clients
  30720 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no  
multi-thread: no
39682.54 requests per second

多并发测试

====== SET ======

  20008 requests completed in 0.31 seconds
  10 parallel clients
  30720 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
64750.81 requests per second
====== GET ======
  20017 requests completed in 0.27 seconds
  10 parallel clients
  30720 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
73591.91 requests per second

03 Redis 安装版

单并发测试

====== SET ======

  200000 requests completed in 7.21 seconds
  1 parallel clients  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
27735.40 requests per second
====== GET ======
  200000 requests completed in 7.06 seconds
  1 parallel clients  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
28312.57 requests per second

多并发测试

====== SET ======

  200000 requests completed in 2.31 seconds
  10 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
86730.27 requests per second
====== GET ======
  200000 requests completed in 2.29 seconds
  10 parallel clients  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
87221.98 requests per second

04 -P 测试

单并发

====== SET ======
  200000 requests completed in 0.89 seconds
  1 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
223964.16 requests per second
====== GET ======
  200000 requests completed in 0.81 seconds
  1 parallel clients  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
247524.75 requests per second

多并发

====== SET ======

  200000 requests completed in 0.29 seconds
  10 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
687285.19 requests per second
====== GET ======
  200000 requests completed in 0.27 seconds
  10 parallel clients  3 bytes payload
  keep alive: 1
  host configuration "save": 900 1 300 10 60 10000
  host configuration "appendonly": no
  multi-thread: no
751879.69 requests per second

明显可以看出 换了一台的服务器,CPU没有上一台多,可用内存剩余少,单单只是HZ不一样,但结果相差甚大。

其他运行测试,当一台32G的内存服务器,Redis跑到 7G 的时候 QPS 从 20W+ 一路下跌,跑到31G的时候QPS大约为 3W+。(这个大家可以自测 把 -d 值给大就行)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值