文档章节

Redis 压力测试说明

舒文suven
 舒文suven
发布于 2018/07/16 18:06
字数 1362
阅读 381
收藏 0

Redis 压力测试说明

redis压力测试
2014-03-24 21:41:07| 分类: 默认分类 | 标签:redis |举报|字号 订阅 这几天对比测试mongodb、redis、pg的性能,主要是在消息队列、消息处理、用户经纬度更新等大并发、大数据量、增删改查频繁的业务场景下,这几种数据库的性能表现,下面就记录下redis下的压力测试,后续将会把redis的业务模拟测试写下。 redis自带有redis-benchmark工具做压力测试,参数如下: [root@db1 ~]# redis-benchmark --help Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>]

-h <hostname> Server hostname (default 127.0.0.1) --主机ip地址 -p <port> Server port (default 6379) --端口 -s <socket> Server socket (overrides host and port) --socket(如果测试在服务器上测可以用socket方式) -c <clients> Number of parallel connections (default 50) --客户端连接数 -n <requests> Total number of requests (default 10000) --总请求数 -d <size> Data size of SET/GET value in bytes (default 2) --set、get的value大小 -dbnum <db> SELECT the specified db number (default 0) --选择哪个数据库测试(一般0-15) -k <boolean> 1=keep alive 0=reconnect (default 1) --是否采用keep alive模式 -r <keyspacelen> Use random keys for SET/GET/INCR, random values for SADD --随机产生键值时的随机数范围 Using this option the benchmark will expand the string rand_int inside an argument with a 12 digits number in the specified range from 0 to keyspacelen-1. The substitution changes every time a command is executed. Default tests use this to hit random keys in the specified range. -P <numreq> Pipeline <numreq> requests. Default 1 (no pipeline). --pipeline的个数(如果使用pipeline会把多个命令封装在一起提高效率) -q Quiet. Just show query/sec values --仅仅查看每秒的查询数 --csv Output in CSV format --用csv方式输出 -l Loop. Run the tests forever --循环次数 -t <tests> 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. --仅打开n个空闲链接

Examples:

Run the benchmark with the default configuration against 127.0.0.1:6379: $ redis-benchmark

Use 20 parallel clients, for a total of 100k requests, against 192.168.1.1: $ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20 --测试set、get、mset、sadd等场景下的性能

Fill 127.0.0.1:6379 with about 1 million keys only using the SET test: $ redis-benchmark -t set -n 1000000 -r 100000000 --测试set随机数的性能

Benchmark 127.0.0.1:6379 for a few commands producing CSV output: $ redis-benchmark -t ping,set,get -n 100000 --csv --使用csv的输出方式测试

Benchmark a specific command line: $ redis-benchmark -r 10000 -n 10000 eval 'return redis.call("ping")' 0 --测试基本命令的速度

Fill a list with 10000 random elements: $ redis-benchmark -r 10000 -n 10000 lpush mylist rand_int --测试list入队的速度

On user specified command lines rand_int is replaced with a random integer with a range of values selected by the -r option.

下面我就测下我的笔记本电脑的redis性能: [root@db1 ~]# redis-benchmark -h 127.0.0.1 -p 6379 -n 100000 -c 20 ====== PING_INLINE ====== 100000 requests completed in 1.09 seconds 20 parallel clients 3 bytes payload keep alive: 1

99.86% <= 1 milliseconds 100.00% <= 2 milliseconds 100.00% <= 2 milliseconds 91659.03 requests per second

====== PING_BULK ====== 100000 requests completed in 1.07 seconds 20 parallel clients 3 bytes payload keep alive: 1

99.94% <= 1 milliseconds 100.00% <= 1 milliseconds 93545.37 requests per second

====== SET ====== 100000 requests completed in 1.03 seconds 20 parallel clients 3 bytes payload keep alive: 1

99.78% <= 1 milliseconds 100.00% <= 1 milliseconds 97087.38 requests per second

====== GET ====== 100000 requests completed in 1.10 seconds 20 parallel clients 3 bytes payload keep alive: 1

99.81% <= 1 milliseconds 100.00% <= 1 milliseconds 90909.09 requests per second

====== INCR ====== 100000 requests completed in 1.09 seconds 20 parallel clients 3 bytes payload keep alive: 1

99.86% <= 1 milliseconds 100.00% <= 1 milliseconds 91911.76 requests per second

====== LPUSH ====== 100000 requests completed in 1.07 seconds 20 parallel clients 3 bytes payload keep alive: 1

99.85% <= 1 milliseconds 100.00% <= 1 milliseconds 93808.63 requests per second

====== LPOP ====== 100000 requests completed in 1.01 seconds 20 parallel clients 3 bytes payload keep alive: 1

99.89% <= 1 milliseconds 100.00% <= 1 milliseconds 98522.17 requests per second

====== SADD ====== 100000 requests completed in 1.04 seconds 20 parallel clients 3 bytes payload keep alive: 1

99.76% <= 1 milliseconds 100.00% <= 1 milliseconds 96153.85 requests per second

====== SPOP ====== 100000 requests completed in 1.11 seconds 20 parallel clients 3 bytes payload keep alive: 1

99.92% <= 1 milliseconds 100.00% <= 1 milliseconds 90171.33 requests per second

====== LPUSH (needed to benchmark LRANGE) ====== 100000 requests completed in 1.09 seconds 20 parallel clients 3 bytes payload keep alive: 1

99.82% <= 1 milliseconds 100.00% <= 1 milliseconds 92081.03 requests per second

====== LRANGE_100 (first 100 elements) ====== 100000 requests completed in 2.53 seconds 20 parallel clients 3 bytes payload keep alive: 1

99.91% <= 1 milliseconds 100.00% <= 2 milliseconds 100.00% <= 2 milliseconds 39603.96 requests per second

====== LRANGE_300 (first 300 elements) ====== 100000 requests completed in 5.17 seconds 20 parallel clients 3 bytes payload keep alive: 1

91.01% <= 1 milliseconds 99.94% <= 2 milliseconds 100.00% <= 2 milliseconds 19346.10 requests per second

====== LRANGE_500 (first 450 elements) ====== 100000 requests completed in 7.41 seconds 20 parallel clients 3 bytes payload keep alive: 1

61.54% <= 1 milliseconds 98.36% <= 2 milliseconds 99.96% <= 3 milliseconds 100.00% <= 4 milliseconds 100.00% <= 4 milliseconds 13498.92 requests per second

====== LRANGE_600 (first 600 elements) ====== 100000 requests completed in 9.49 seconds 20 parallel clients 3 bytes payload keep alive: 1

41.24% <= 1 milliseconds 91.89% <= 2 milliseconds 99.78% <= 3 milliseconds 100.00% <= 4 milliseconds 100.00% <= 4 milliseconds 10541.85 requests per second

====== MSET (10 keys) ====== 100000 requests completed in 1.68 seconds 20 parallel clients 3 bytes payload keep alive: 1

99.28% <= 1 milliseconds 100.00% <= 1 milliseconds 59382.42 requests per second 从以上可以看出,20个客户端,每种场景均有100000次请求:ping、set、get、lpush、lpop、spop等都达到90000多rps,但lrange前100、300、500等就比较慢了,才10000多rps。

再测下set的速度: [root@db1 ~]# redis-benchmark -t set -n 1000000 -r 100000000 ====== SET ====== 1000000 requests completed in 10.56 seconds 50 parallel clients 3 bytes payload keep alive: 1

98.65% <= 1 milliseconds 99.90% <= 2 milliseconds 99.99% <= 3 milliseconds 100.00% <= 3 milliseconds 94741.83 requests per second 每秒94741次,非常快

再来测试下list的入队速度: [root@db1 ~]# redis-benchmark -r 100000 -n 100000 lpush mylist rand_int ====== lpush mylist rand_int ====== 100000 requests completed in 0.97 seconds 50 parallel clients 3 bytes payload keep alive: 1

98.83% <= 1 milliseconds 100.00% <= 1 milliseconds 102774.92 requests per second 超过了10w次。

用法很简单,不做过多说明。

© 著作权归作者所有

舒文suven
粉丝 13
博文 56
码字总数 81337
作品 0
广州
后端工程师
私信 提问
Redis压力测试说明

Redis压力测试说明 redis-benchmark是redis自带的压力测试工具: 使用方法: 可以使用redis-benchmark –help来显示使用方法: 1、redis-benchmark -t set -c 100 -n 1000000 -r 1000000 -d ...

arvin_qin
2017/05/26
0
0
Tomcat+redis+nginx配置

为客户开发的一个绩效系统,采用了java web的开发方式,使用了一些spring mvc, mybatis之类的框架。相比于oracle ebs的二次开发,这种开发更加灵活,虽然和ebs集成的时候遇到一些问题,但是最...

五大三粗
2015/11/25
10.6K
5
phpredis中的connect和pconnect

http://blog.csdn.net/u013474436/article/details/53118475 参考地址: 现在不管是在缓存方面,还是NoSQL方面,Redis很火也很流行,但是使用方面的经验不是很多,包括Redis的一些优化配置,...

wjw555
2017/10/27
0
0
两级缓存框架 J2Cache 的简单实验

今天对 J2Cache 做了最基本的测试,代码已经开放出来,地址是 http://git.oschina.net/ld/J2Cache 补充为什么要做这个框架: 说实话,OSC 现在还是单个 Tomcat,只不过我们做了一些分流措施将...

红薯
2014/01/07
19K
45
Node.JS vs PHP CLI Server 简单的HTTP服务器性能测试

环境:64位Ubuntu14.04,i5-3230M PHP5.4.31 with ZendOPcache Node.JS 0.10.35 Node.JS 测试var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Co......

eechen
2015/01/19
3.8K
28

没有更多内容

加载失败,请刷新页面

加载更多

Spring Boot Actuator监控使用详解

在企业级应用中,学习了如何进行SpringBoot应用的功能开发,以及如何写单元测试、集成测试等还是不够的。在实际的软件开发中还需要:应用程序的监控和管理。SpringBoot的Actuator模块实现了应...

程序新视界
30分钟前
6
0
JDBC+C3P0+DBCP 基本使用

1.概述 这篇文章主要说了JDBC的基本使用,包括Statement,PreparedStatement,JDBC的连接,Mysql创建用户创建数据表,C3P0的连接与配置,DBCP的连接与配置. 2.mysql的处理 这里的JDBC使用Mysql作为...

Blueeeeeee
今天
7
0
MVC Linux下开发及部署

linux使用的是 Ubuntu 64 位 18.04.2 LTS 首先复制C:\Program Files (x86)\Embarcadero\Studio\20.0\PAServer 下 LinuxPAServer20.0.tar.gz 到 linux 目录下 运行链接编译程序 delphi环境配置......

苏兴迎
今天
11
0
3.控件及其属性

1.文本 2.按钮

横着走的螃蟹
今天
9
0
安装Genymotion模拟器慢的解决方案

第一步点击下载, C:\Users\Administrator\AppData\Local\Genymobile\genymotion.log 中搜索 ova 会发现这个文件 使用迅雷下载即可. 在 虚拟机中导入这个.ova 文件 即可安装...

chenhongjiang
今天
6
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部