首页 > 数据库 >25. Redis---性能测试

25. Redis---性能测试

时间:2022-08-20 17:22:38浏览次数:88  
标签:25 Redis per --- second LRANGE 测试 requests

1. 前言

为了解 Redis 在不同配置环境下的性能表现,Redis 提供了一种行性能测试工具 redis-benchmark(也称压力测试工具),它通过同时执行多组命令实现对 Redis 的性能测试。

性能测试的作用是让我们了解 Redis 服务器的性能优劣。在实际的业务场景中,性能测试是必不可少的。在业务系统上线之前,我们都需要清楚地了解 Redis 服务器的性能,从而避免发生某些意外情况,比如数据量过大会导致服务器宕机等。

2. 测试命令格式

执行测试命令,要在 Redis 的安装目录下执行,命令如下所示:

redis-benchmark [option] [option value]

其中 option 为可选参数, option value 为具体的参数值。 redis-benchmark 命令的可选参数如下所示:

Benchmark性能测试参数
参数选项说明
-h 指定服务器主机名。
-p 指定服务器端口。
-s 指定服务器 socket。
-c 指定并发连接数。
-n 指定请求的具体数量。
-d 以字节的形式指定 SET/GET 值的数据大小。
-k 1 表示 keep alive;0 表示 reconnect,默认为 1。
-r SET/GET/INCR 使用随机 key, SADD 使用随机值。
-P Pipeline 请求
-q 强制退出 Redis,仅显示 query/sec 值。
--csv 以 CSV 格式输出。
-l 生成循环,永久执行测试。
-t 仅运行以逗号分隔的测试命令列表。
-I(大写i) 空闲模式,打开 N 个空闲连接并等待连接。



在 Windows 系统下,其目录文件如图所示:

Redis压力测试
图1:Redis Benchmark性能测试

3. 执行测试命令

1) Windows环境

在 Windows 10 系统环境下,同时执行了 10000 个命令来检测 Redis 服务器的性能,示例如下:

D:\Redis-x64-5.0.10>redis-benchmark.exe -n 10000 -q
PING_INLINE: 21786.49 requests per second
PING_BULK: 21231.42 requests per second
#每秒执行22935.78个请求
SET: 22935.78 requests per second
GET: 22573.36 requests per second
INCR: 19011.41 requests per second
LPUSH: 7473.84 requests per second
RPUSH: 20618.56 requests per second
LPOP: 17793.60 requests per second
RPOP: 21367.52 requests per second
SADD: 15847.86 requests per second
HSET: 21551.72 requests per second
SPOP: 19531.25 requests per second
LPUSH (needed to benchmark LRANGE): 18348.62 requests per second
LRANGE_100 (first 100 elements): 6835.27 requests per second
LRANGE_300 (first 300 elements): 4535.15 requests per second
LRANGE_500 (first 450 elements): 3913.89 requests per second
LRANGE_600 (first 600 elements): 3177.63 requests per second
MSET (10 keys): 15128.59 requests per second

注意:若是 Linux 系统,其每秒钟执行的请求数量是 Windows 系统的好几倍。

2) Linux环境

Linux 环境下,Redis 的性能测试结果,如下所示:

$ redis-benchmark -n 10000  -q
PING_INLINE: 141043.72 requests per second
PING_BULK: 142857.14 requests per second
#服务器每秒执行的请求数量
SET: 141442.72 requests per second
GET: 145348.83 requests per second
INCR: 137362.64 requests per second
LPUSH: 145348.83 requests per second
LPOP: 146198.83 requests per second
SADD: 146198.83 requests per second
SPOP: 149253.73 requests per second
LPUSH (needed to benchmark LRANGE): 148588.42 requests per second
LRANGE_100 (first 100 elements): 58411.21 requests per second
LRANGE_300 (first 300 elements): 21195.42 requests per second
LRANGE_500 (first 450 elements): 14539.11 requests per second
LRANGE_600 (first 600 elements): 10504.20 requests per second
MSET (10 keys): 93283.58 requests per second

3) 执行指定的测试命令 

带参数的命令,使用示例如下:

D:\Redis-x64-5.0.10>redis-benchmark.exe -h 127.0.0.1 -p 6379 -n 10000 -t set,get,lpush -q
SET: 17064.85 requests per second
GET: 16051.36 requests per second
LPUSH: 14224.75 requests per second

 

标签:25,Redis,per,---,second,LRANGE,测试,requests
From: https://www.cnblogs.com/jiajunling/p/16608198.html

相关文章

  • SQLAlchemy学习-10. validates()校验器
    前言向属性添加“验证”的一种快速方法是使用validates()装饰器。校验器属性验证器可以引发异常,停止改变属性值的过程,或者可以将给定值更改为不同的值。与所有属性扩......
  • 22. Redis---地理位置
    1.前言在Redis3.2版本中,新增了存储地理位置信息的功能,即GEO(英文全称geographic),它的底层通过Redis有序集合(zset)实现。不过RedisGEO并没有与zset共用一套的命令......
  • "蔚来杯"2022牛客暑期多校训练营1 G-Lexicographical Maximum
    问题描述EibwenisanewbieinPython.Youmightknowthatwhenyouinputanumberinthecommandline,yourPythonprogramwillreceiveastringcontainingth......
  • Objective-C的IDE开发集成环境
    AppCodeforMac是适用于Mac操作系统的全新智能Objective-C的IDE开发集成环境,帮助开发者来开发Mac、iphone和iPad等iOS系统的相关应用程序,是从事iOS开发工作者必不可少的工......
  • go protoc-gen-go 安装记录
    按照教程安装gogetgithub.com/golang/protobuf/protoc-gen-go报错如下错误  我使用的go版本是1.17。而Go1.17版使用goinstall安装依赖。所以应该按照......
  • Redis知识点总结
    Redis的淘汰策略有哪几种?volatile-lru从已设置过期时间的数据集中挑选最近最少使用的数据淘汰volatile-ttl从已设置过期时间的数据集中挑选将要过期的数据淘汰......
  • CSS3 响应式布局: @media (min/max-width:***) @font-face
    https://www.cnblogs.com/hualiu0/p/5319046.html 响应式布局responsivedesign@media属性bootstrap css分析:@media(min-width:768px){body{***}}use@me......
  • 一些关于Viewport与device-width的东西~
    https://www.cnblogs.com/koukouyifan/p/4066567.html进行移动web开发已经有一年多的时间了,期间遇到了一些令人很困惑的东西。比如:我们经常使用的<metaname="viewpor......
  • "蔚来杯"2022牛客暑期多校训练营1 - D Mocha and Railgun
    问题描述ThereisacandystorenearMocha'sschool.It'ssaidthatthestorekeeper,Dagashiya,cancasttherailgunspell.TobethemostpowerfulMahouShouj......
  • A-想要更多的0_2022河南萌新联赛第(六)场:郑州大学 (nowcoder.com)
    A-想要更多的0_2022河南萌新联赛第(六)场:郑州大学(nowcoder.com)这个题思路倒是很好想到主要是处理[0,n]区间内0出现的次数考虑这个问题比如对3891205举例。我们取到......