婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁(yè) > 知識(shí)庫(kù) > 淺談redis的maxmemory設(shè)置以及淘汰策略

淺談redis的maxmemory設(shè)置以及淘汰策略

熱門(mén)標(biāo)簽:西藏教育智能外呼系統(tǒng)價(jià)格 竹間科技AI電銷機(jī)器人 玄武湖地圖標(biāo)注 小紅書(shū)怎么地圖標(biāo)注店 地圖標(biāo)注費(fèi)用 百度商家地圖標(biāo)注怎么做 地圖標(biāo)注如何即時(shí)生效 最簡(jiǎn)單的百度地圖標(biāo)注 太原營(yíng)銷外呼系統(tǒng)

redis的maxmemory參數(shù)用于控制redis可使用的最大內(nèi)存容量。如果超過(guò)maxmemory的值,就會(huì)動(dòng)用淘汰策略來(lái)處理expaire字典中的鍵。

關(guān)于redis的淘汰策略:

Redis提供了下面幾種淘汰策略供用戶選擇,其中默認(rèn)的策略為noeviction策略:

·   noeviction:當(dāng)內(nèi)存使用達(dá)到閾值的時(shí)候,所有引起申請(qǐng)內(nèi)存的命令會(huì)報(bào)錯(cuò)。

·   allkeys-lru:在主鍵空間中,優(yōu)先移除最近未使用的key。

·   volatile-lru:在設(shè)置了過(guò)期時(shí)間的鍵空間中,優(yōu)先移除最近未使用的key。

·   allkeys-random:在主鍵空間中,隨機(jī)移除某個(gè)key。

·   volatile-random:在設(shè)置了過(guò)期時(shí)間的鍵空間中,隨機(jī)移除某個(gè)key。

·   volatile-ttl:在設(shè)置了過(guò)期時(shí)間的鍵空間中,具有更早過(guò)期時(shí)間的key優(yōu)先移除。

PS:

關(guān)于maxmemory的設(shè)置,如果redis的應(yīng)用場(chǎng)景是作為db使用,那不要設(shè)置這個(gè)選項(xiàng),因?yàn)閐b是不能容忍丟失數(shù)據(jù)的。

如果作為cache使用,則可以啟用這個(gè)選項(xiàng)(其實(shí)既然有淘汰策略,那就是cache了。。。)

但是在集群環(huán)境下(尤其是有多個(gè)slavers的情形),maxmeomory的值并不是實(shí)際redis使用的內(nèi)存,這個(gè)選項(xiàng)值并沒(méi)有包括slaver的output buffer。

redis早期版本出過(guò)一個(gè)bug,在多個(gè)slaver的情形下,設(shè)置了maxmemory值,同時(shí)設(shè)定了淘汰策略,會(huì)造成master上的數(shù)據(jù)被漸漸擦除。

antirez先生給出了這個(gè)問(wèn)題的原因:

The issue happens for the following reason:
 
Redis reached the configured limit, so it tries to expire keys.
Evicting keys turns into explicit DELs sent to slaves, since masters control the eviction of slaves for well known reasons.
But this way if there are enough slaves, emitting the protocol in the output buffers will actually take more memory than the amount freed removing keys...
So the key eviction process starts to enter into an infinite loop.
Up to a given point the fact that there is a static buffer part in the output queue of every client (including slaves) mitigate this in certain conditions, but once Redis can't use the output buffer but must use the queue of objects the infinite loop is triggered. 

簡(jiǎn)單說(shuō)來(lái),刪除過(guò)期鍵,需要產(chǎn)生del命令發(fā)送給slaver,如果slaver足夠多,output buffer將會(huì)占用足夠多的內(nèi)存,導(dǎo)致更多的鍵過(guò)期,如此往復(fù),陷入了無(wú)線循環(huán)。

解決方案有多種,比如output buffer可以不計(jì)入maxmemory。

因此,在3.0版本的配置說(shuō)明中有了以下表述:

# WARNING: If you have slaves attached to an instance with maxmemory on,
# the size of the output buffers needed to feed the slaves are subtracted
# from the used memory count, so that network problems / resyncs will
# not trigger a loop where keys are evicted, and in turn the output
# buffer of slaves is full with DELs of keys evicted triggering the deletion
# of more keys, and so forth until the database is completely emptied.
#
# In short... if you have slaves attached it is suggested that you set a lower
# limit for maxmemory so that there is some free RAM on the system for slave
# output buffers (but this is not needed if the policy is 'noeviction').
#
# maxmemory bytes>/bytes> 

由此可見(jiàn),如果有slaver的情況下,建議適當(dāng)調(diào)低maxmemory,給output buffer留出一定的可用空間是合理的。

以上這篇淺談redis的maxmemory設(shè)置以及淘汰策略就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • Redis中LRU淘汰策略的深入分析
  • 關(guān)于redis Key淘汰策略的實(shí)現(xiàn)方法
  • 淺談Redis緩存有哪些淘汰策略

標(biāo)簽:澳門(mén) 揚(yáng)州 廣東 景德鎮(zhèn) 林芝 香港 贛州 唐山

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《淺談redis的maxmemory設(shè)置以及淘汰策略》,本文關(guān)鍵詞  淺談,redis,的,maxmemory,設(shè)置,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《淺談redis的maxmemory設(shè)置以及淘汰策略》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于淺談redis的maxmemory設(shè)置以及淘汰策略的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 武清区| 六安市| 闽侯县| 孟村| 阿尔山市| 陆川县| 乌拉特前旗| 林口县| 嘉定区| 安平县| 宁夏| 龙川县| 香港 | 长沙市| 察隅县| 菏泽市| 雷山县| 偃师市| 成武县| 集安市| 闵行区| 姜堰市| 阳谷县| 永德县| 阿克陶县| 丰顺县| 调兵山市| 定兴县| 古丈县| 福建省| 临江市| 土默特右旗| 孙吴县| 汉源县| 沙雅县| 峨山| 元朗区| 大田县| 湖北省| 黄梅县| 九龙县|