缓存架构之09:对项目的主从redis架构进行QPS压测以及水平扩容支撑更高QPS

你如果要对自己刚刚搭建好的redis做一个基准的压测,测一下你的redis的性能和QPS(query per second)redis自己提供的redis-benchmark压测工具,是最快捷最方便的,当然啦,这个工具比较简单,用一些简单的操作和场景去压测1、对redis读写分离架构进行压测,单实例写QPS+单实例读QPSredis-3.2.8/src./redis-benchmark -h 192.168.31.187-cNumber of parallel connections (default 50)-nTotal number of requests (default 100000)-d Data size of SET/GET value in bytes (default 2)

根据你自己的高峰期的访问量,在高峰期,瞬时最大用户量会达到10万+,-c 100000,-n 10000000,-d 50

各种基准测试,直接出来

1核1G,虚拟机

====== PING_INLINE ======

  100000 requests completed in 1.28 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

99.78% <= 1 milliseconds

99.93% <= 2 milliseconds

99.97% <= 3 milliseconds

100.00% <= 3 milliseconds

78308.54 requests per second

====== PING_BULK ======

  100000 requests completed in 1.30 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

99.87% <= 1 milliseconds

100.00% <= 1 milliseconds

76804.91 requests per second

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

  100000 requests completed in 2.50 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

5.95% <= 1 milliseconds

99.63% <= 2 milliseconds

99.93% <= 3 milliseconds

99.99% <= 4 milliseconds

100.00% <= 4 milliseconds

40032.03 requests per second

====== GET ======

  100000 requests completed in 1.30 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

99.73% <= 1 milliseconds

100.00% <= 2 milliseconds

100.00% <= 2 milliseconds

76628.35 requests per second

====== INCR ======

  100000 requests completed in 1.90 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

80.92% <= 1 milliseconds

99.81% <= 2 milliseconds

99.95% <= 3 milliseconds

99.96% <= 4 milliseconds

99.97% <= 5 milliseconds

100.00% <= 6 milliseconds

52548.61 requests per second

====== LPUSH ======

  100000 requests completed in 2.58 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

3.76% <= 1 milliseconds

99.61% <= 2 milliseconds

99.93% <= 3 milliseconds

100.00% <= 3 milliseconds

38684.72 requests per second

====== RPUSH ======

  100000 requests completed in 2.47 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

6.87% <= 1 milliseconds

99.69% <= 2 milliseconds

99.87% <= 3 milliseconds

99.99% <= 4 milliseconds

100.00% <= 4 milliseconds

40469.45 requests per second

====== LPOP ======

  100000 requests completed in 2.26 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

28.39% <= 1 milliseconds

99.83% <= 2 milliseconds

100.00% <= 2 milliseconds

44306.60 requests per second

====== RPOP ======

  100000 requests completed in 2.18 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

36.08% <= 1 milliseconds

99.75% <= 2 milliseconds

100.00% <= 2 milliseconds

45871.56 requests per second

====== SADD ======

  100000 requests completed in 1.23 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

99.94% <= 1 milliseconds

100.00% <= 2 milliseconds

100.00% <= 2 milliseconds

81168.83 requests per second

====== SPOP ======

  100000 requests completed in 1.28 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

99.80% <= 1 milliseconds

99.96% <= 2 milliseconds

99.96% <= 3 milliseconds

99.97% <= 5 milliseconds

100.00% <= 5 milliseconds

78369.91 requests per second

====== LPUSH (needed to benchmark LRANGE) ======

  100000 requests completed in 2.47 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

15.29% <= 1 milliseconds

99.64% <= 2 milliseconds

99.94% <= 3 milliseconds

100.00% <= 3 milliseconds

40420.37 requests per second

====== LRANGE_100 (first 100 elements) ======

  100000 requests completed in 3.69 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

30.86% <= 1 milliseconds

96.99% <= 2 milliseconds

99.94% <= 3 milliseconds

99.99% <= 4 milliseconds

100.00% <= 4 milliseconds

27085.59 requests per second

====== LRANGE_300 (first 300 elements) ======

  100000 requests completed in 10.22 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

0.03% <= 1 milliseconds

5.90% <= 2 milliseconds

90.68% <= 3 milliseconds

95.46% <= 4 milliseconds

97.67% <= 5 milliseconds

99.12% <= 6 milliseconds

99.98% <= 7 milliseconds

100.00% <= 7 milliseconds

9784.74 requests per second

====== LRANGE_500 (first 450 elements) ======

  100000 requests completed in 14.71 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

0.00% <= 1 milliseconds

0.07% <= 2 milliseconds

1.59% <= 3 milliseconds

89.26% <= 4 milliseconds

97.90% <= 5 milliseconds

99.24% <= 6 milliseconds

99.73% <= 7 milliseconds

99.89% <= 8 milliseconds

99.96% <= 9 milliseconds

99.99% <= 10 milliseconds

100.00% <= 10 milliseconds

6799.48 requests per second

====== LRANGE_600 (first 600 elements) ======

  100000 requests completed in 18.56 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

0.00% <= 2 milliseconds

0.23% <= 3 milliseconds

1.75% <= 4 milliseconds

91.17% <= 5 milliseconds

98.16% <= 6 milliseconds

99.04% <= 7 milliseconds

99.83% <= 8 milliseconds

99.95% <= 9 milliseconds

99.98% <= 10 milliseconds

100.00% <= 10 milliseconds

5387.35 requests per second

====== MSET (10 keys) ======

  100000 requests completed in 4.02 seconds

  50 parallel clients

  3 bytes payload

  keep alive: 1

0.01% <= 1 milliseconds

53.22% <= 2 milliseconds

99.12% <= 3 milliseconds

99.55% <= 4 milliseconds

99.70% <= 5 milliseconds

99.90% <= 6 milliseconds

99.95% <= 7 milliseconds

100.00% <= 8 milliseconds

24869.44 requests per second

我们这个读写分离这一块的第一讲

大部分情况下来说,看你的服务器的机器性能和配置,机器越牛逼,配置越高

单机上十几万,单机上二十万

很多公司里,给一些低配置的服务器,操作复杂度

大公司里,都是公司会提供统一的云平台,比如京东、腾讯、BAT、其他的一些、小米、美团

虚拟机,低配

搭建一些集群,专门为某个项目,搭建的专用集群,4核4G内存,比较复杂的操作,数据比较大

几万,单机做到,差不多了

redis提供的高并发,至少到上万,没问题

几万~十几万/二十万不等

QPS,自己不同公司,不同服务器,自己去测试,跟生产环境还有区别

生产环境,大量的网络请求的调用,网络本身就有开销,你的redis的吞吐量就不一定那么高了

QPS的两个杀手:一个是复杂操作,lrange,挺多的; value很大,2 byte,我之前用redis做大规模的缓存

做商品详情页的cache,可能是需要把大串数据,拼接在一起,作为一个json串,大小可能都几k,几个byte

2、水平扩容redis读节点,提升度吞吐量

就按照上一节课讲解的,再在其他服务器上搭建redis从节点,单个从节点读请QPS在5万左右,两个redis从节点,所有的读请求打到两台机器上去,承载整个集群读QPS在10万+

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,098评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,213评论 2 380
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,960评论 0 336
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,519评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,512评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,533评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,914评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,574评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,804评论 1 296
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,563评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,644评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,350评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,933评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,908评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,146评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,847评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,361评论 2 342

推荐阅读更多精彩内容