文档章节

Redis 压力测试说明

舒文joven
 舒文joven
发布于 07/16 18:06
字数 1362
阅读 13
收藏 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次。

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

© 著作权归作者所有

共有 人打赏支持
舒文joven
粉丝 10
博文 31
码字总数 58140
作品 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
8.8K
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
17.8K
45
nginx负载均衡以及静态资源的反向代理实施方案

nginx负载均衡以及静态资源的反向代理实施方案 作者:袁旭云 nginx介绍 nginx (发音同 engine x)是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个B...

IT小香猪
2016/09/01
477
1

没有更多内容

加载失败,请刷新页面

加载更多

下一页

Confluence 6 删除垃圾内容

属性(profile)垃圾 属性垃圾的定义为,一个垃圾用户在 Confluence 创建了用户,但是这个用户在自己的属性页面中添加了垃圾 URL。 如果你有很多垃圾用户在你的系统中创建了属性,你可以使用...

honeymose
今天
0
0
qduoj~前端~二次开发~打包docker镜像并上传到阿里云容器镜像仓库

上一篇文章https://my.oschina.net/finchxu/blog/1930017记录了怎么在本地修改前端,现在我要把我的修改添加到部署到本地的前端的docker容器中,然后打包这个容器成为一个本地镜像,然后把这...

虚拟世界的懒猫
今天
1
0
UML中 的各种符号含义

Class Notation A class notation consists of three parts: Class Name The name of the class appears in the first partition. Class Attributes Attributes are shown in the second par......

hutaishi
今天
1
0
20180818 上课截图

小丑鱼00
今天
1
0
Springsecurity之SecurityContextHolderStrategy

注:下面分析的版本是spring-security-4.2.x,源码的github地址是: https://github.com/spring-projects/spring-security/tree/4.2.x 先上一张图: 图1 SecurityContextHolderStrategy的三个......

汉斯-冯-拉特
今天
1
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部