文档章节

Redis 压力测试说明

舒文suven
 舒文suven
发布于 07/16 18:06
字数 1362
阅读 36
收藏 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
博文 36
码字总数 67008
作品 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
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
0
28

没有更多内容

加载失败,请刷新页面

加载更多

码云项目100,水一发

简单回顾一下: 早期构想最多的,是希望能将PHP一些类和编码分区做得更细,所以很多尝试。但不得不说,PHP的功能过于单一,是的,也许写C/C++扩展,可以解决问题,那我为什么不用C#或者Golan...

曾建凯
今天
3
0
Spring应用学习——AOP

1. AOP 1. AOP:即面向切面编程,采用横向抽取机制,取代了传统的继承体系的重复代码问题,如下图所示,性能监控、日志记录等代码围绕业务逻辑代码,而这部分代码是一个高度重复的代码,也就...

江左煤郎
今天
4
0
eclipse的版本

Eclipse各版本代号一览表 Eclipse的设计思想是:一切皆插件。Eclipse核心很小,其它所有功能都以插件的形式附加于Eclipse核心之上。 Eclipse基本内核包括:图形API(SWT/Jface),Java开发环...

mdoo
今天
3
0
SpringBoot源码:启动过程分析(一)

本文主要分析 SpringBoot 的启动过程。 SpringBoot的版本为:2.1.0 release,最新版本。 一.时序图 还是老套路,先把分析过程的时序图摆出来:时序图-SpringBoot2.10启动分析 二.源码分析 首...

Jacktanger
今天
6
0
小白带你认识netty(二)之netty服务端启动(上)

上一章 中的标准netty启动代码中,ServerBootstrap到底是如何启动的呢?这一章我们来瞅下。 server.group(bossGroup, workGroup);server.channel(NioServerSocketChannel.class).optio...

天空小小
今天
4
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部