緩存架構(gòu)之09:對(duì)項(xiàng)目的主從redis架構(gòu)進(jìn)行QPS壓測以及水平擴(kuò)容支撐更高QPS

你如果要對(duì)自己剛剛搭建好的redis做一個(gè)基準(zhǔn)的壓測表窘,測一下你的redis的性能和QPS(query per second)redis自己提供的redis-benchmark壓測工具,是最快捷最方便的,當(dāng)然啦翎嫡,這個(gè)工具比較簡單湃鹊,用一些簡單的操作和場景去壓測1村缸、對(duì)redis讀寫分離架構(gòu)進(jìn)行壓測汉形,單實(shí)例寫QPS+單實(shí)例讀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)

根據(jù)你自己的高峰期的訪問量擅憔,在高峰期鸵闪,瞬時(shí)最大用戶量會(huì)達(dá)到10萬+,-c 100000雕欺,-n 10000000岛马,-d 50

各種基準(zhǔn)測試,直接出來

1核1G屠列,虛擬機(jī)

====== 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

我們這個(gè)讀寫分離這一塊的第一講

大部分情況下來說啦逆,看你的服務(wù)器的機(jī)器性能和配置,機(jī)器越牛逼笛洛,配置越高

單機(jī)上十幾萬夏志,單機(jī)上二十萬

很多公司里,給一些低配置的服務(wù)器苛让,操作復(fù)雜度

大公司里沟蔑,都是公司會(huì)提供統(tǒng)一的云平臺(tái),比如京東狱杰、騰訊瘦材、BAT、其他的一些仿畸、小米食棕、美團(tuán)

虛擬機(jī),低配

搭建一些集群错沽,專門為某個(gè)項(xiàng)目簿晓,搭建的專用集群,4核4G內(nèi)存千埃,比較復(fù)雜的操作憔儿,數(shù)據(jù)比較大

幾萬,單機(jī)做到放可,差不多了

redis提供的高并發(fā)谒臼,至少到上萬,沒問題

幾萬~十幾萬/二十萬不等

QPS耀里,自己不同公司蜈缤,不同服務(wù)器,自己去測試备韧,跟生產(chǎn)環(huán)境還有區(qū)別

生產(chǎn)環(huán)境劫樟,大量的網(wǎng)絡(luò)請(qǐng)求的調(diào)用痪枫,網(wǎng)絡(luò)本身就有開銷织堂,你的redis的吞吐量就不一定那么高了

QPS的兩個(gè)殺手:一個(gè)是復(fù)雜操作叠艳,lrange,挺多的; value很大易阳,2 byte附较,我之前用redis做大規(guī)模的緩存

做商品詳情頁的cache,可能是需要把大串?dāng)?shù)據(jù)潦俺,拼接在一起拒课,作為一個(gè)json串,大小可能都幾k事示,幾個(gè)byte

2早像、水平擴(kuò)容redis讀節(jié)點(diǎn),提升度吞吐量

就按照上一節(jié)課講解的肖爵,再在其他服務(wù)器上搭建redis從節(jié)點(diǎn)卢鹦,單個(gè)從節(jié)點(diǎn)讀請(qǐng)QPS在5萬左右,兩個(gè)redis從節(jié)點(diǎn)劝堪,所有的讀請(qǐng)求打到兩臺(tái)機(jī)器上去冀自,承載整個(gè)集群讀QPS在10萬+

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市秒啦,隨后出現(xiàn)的幾起案子熬粗,更是在濱河造成了極大的恐慌,老刑警劉巖余境,帶你破解...
    沈念sama閱讀 207,113評(píng)論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件驻呐,死亡現(xiàn)場離奇詭異,居然都是意外死亡葛超,警方通過查閱死者的電腦和手機(jī)暴氏,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,644評(píng)論 2 381
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來绣张,“玉大人答渔,你說我怎么就攤上這事〗暮” “怎么了沼撕?”我有些...
    開封第一講書人閱讀 153,340評(píng)論 0 344
  • 文/不壞的土叔 我叫張陵,是天一觀的道長芜飘。 經(jīng)常有香客問我务豺,道長,這世上最難降的妖魔是什么嗦明? 我笑而不...
    開封第一講書人閱讀 55,449評(píng)論 1 279
  • 正文 為了忘掉前任笼沥,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘奔浅。我一直安慰自己馆纳,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,445評(píng)論 5 374
  • 文/花漫 我一把揭開白布汹桦。 她就那樣靜靜地躺著鲁驶,像睡著了一般。 火紅的嫁衣襯著肌膚如雪舞骆。 梳的紋絲不亂的頭發(fā)上钥弯,一...
    開封第一講書人閱讀 49,166評(píng)論 1 284
  • 那天,我揣著相機(jī)與錄音督禽,去河邊找鬼脆霎。 笑死,一個(gè)胖子當(dāng)著我的面吹牛狈惫,可吹牛的內(nèi)容都是我干的绪穆。 我是一名探鬼主播,決...
    沈念sama閱讀 38,442評(píng)論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼虱岂,長吁一口氣:“原來是場噩夢(mèng)啊……” “哼玖院!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起第岖,我...
    開封第一講書人閱讀 37,105評(píng)論 0 261
  • 序言:老撾萬榮一對(duì)情侶失蹤难菌,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后蔑滓,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體郊酒,經(jīng)...
    沈念sama閱讀 43,601評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,066評(píng)論 2 325
  • 正文 我和宋清朗相戀三年键袱,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了燎窘。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,161評(píng)論 1 334
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡蹄咖,死狀恐怖褐健,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情澜汤,我是刑警寧澤蚜迅,帶...
    沈念sama閱讀 33,792評(píng)論 4 323
  • 正文 年R本政府宣布,位于F島的核電站俊抵,受9級(jí)特大地震影響谁不,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜徽诲,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,351評(píng)論 3 307
  • 文/蒙蒙 一刹帕、第九天 我趴在偏房一處隱蔽的房頂上張望吵血。 院中可真熱鬧,春花似錦偷溺、人聲如沸践瓷。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,352評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至喷舀,卻和暖如春砍濒,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背硫麻。 一陣腳步聲響...
    開封第一講書人閱讀 31,584評(píng)論 1 261
  • 我被黑心中介騙來泰國打工爸邢, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人拿愧。 一個(gè)月前我還...
    沈念sama閱讀 45,618評(píng)論 2 355
  • 正文 我出身青樓杠河,卻偏偏與公主長得像,于是被迫代替她去往敵國和親浇辜。 傳聞我的和親對(duì)象是個(gè)殘疾皇子券敌,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,916評(píng)論 2 344

推薦閱讀更多精彩內(nèi)容

  • 5/15/2017 7:06:35 PM 縱觀各大組件,配置文件占據(jù)極其重要的地位柳洋〈纾可配置化也是當(dāng)下開發(fā)的一流行趨...
    愛做夢(mèng)的胖子閱讀 4,418評(píng)論 0 8
  • =========================================================...
    lavor閱讀 3,484評(píng)論 0 5
  • Redis 配置文件示例 注意:想要讀取配置文件,Redis的第一個(gè)參數(shù)必須是文件的路徑 ./redis-serv...
    起個(gè)名忒難閱讀 1,190評(píng)論 0 1
  • # redis 配置文件示例# 當(dāng)你需要為某個(gè)配置項(xiàng)指定內(nèi)存大小的時(shí)候熊镣,必須要帶上單位卑雁,# 通常的格式就是 1k ...
    誰在烽煙彼岸閱讀 350評(píng)論 0 0
  • # redis 配置文件示例 # 當(dāng)你需要為某個(gè)配置項(xiàng)指定內(nèi)存大小的時(shí)候,必須要帶上單位绪囱, # 通常的格式就是 1...
    iyimao閱讀 790評(píng)論 0 2