Thuta Learning
Redis
AdvancedData & Databasesအခြေခံ

Maxmemory နှင့် Eviction Policies

Redisသင်ခန်းစာ 19

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Maxmemory နှင့် Eviction Policies concept ကို နားလည်ရှင်းပြနိုင်ရန်
  • နမူနာ Redis command/code ကို ကိုယ်တိုင် run ပြီး output စစ်နိုင်ရန်
  • Tutorial Platform project နှင့် production scenario တွင် မှန်ကန်စွာအသုံးချနိုင်ရန်

နားလည်ထားရမယ့် အချက်

`maxmemory` ပြည့်သောအခါ policy အလိုက် keys ဖယ်သို့ writes reject လုပ်ပါတယ်။ `allkeys-lru/lfu` က cache workloads၊ `volatile-*` က TTL ပါ keys သာရွေး၊ `noeviction` က writes reject လုပ်ပါတယ်။ Redis eviction သည် sampled approximation ဖြစ်ပြီး replication/AOF buffers အတွက် operating-system headroom ချန်ရပါတယ်။

လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်

Dedicated catalog-cache instance တွင် `allkeys-lfu` စမ်းပြီး hit ratio၊ evicted_keys၊ latency ကို load test လုပ်မယ်။ Session instance တွင် accidental eviction မဖြစ်အောင် separate capacity/policy သတ်မှတ်မယ်။ Alert ကို used_memory/maxmemory တစ်ခုတည်းမဟုတ်ဘဲ eviction rate နဲ့ miss rate ပါထည့်မယ်။

အတူတူ စမ်းရေးကြည့်မယ်

shell
CONFIG GET maxmemory
CONFIG GET maxmemory-policy
CONFIG SET maxmemory 2gb
CONFIG SET maxmemory-policy allkeys-lfu
INFO stats
INFO memory
You should see
Configured ceiling၊ policy နှင့် eviction counters ကိုစစ်နိုင်မည်။

၅ မိနစ် စမ်းကြည့်

Pure cache၊ session store၊ mixed workload သုံးမျိုးအတွက် policy recommendation နဲ့ reason ရေးပါ။

သတိလေးတစ်ချက်

Runtime `CONFIG SET` သာလုပ်ပြီး config/automation မပြင်လျှင် restart နောက် setting ပျောက်နိုင်ပါတယ်။

Redis — Key Eviction — Redis

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Runtime `CONFIG SET` သာလုပ်ပြီး config/automation မပြင်လျှင် restart နောက် setting ပျောက်နိုင်ပါတယ်။
  • နမူနာ command ကို production Redis ပေါ် တိုက်ရိုက်မစမ်းဘဲ local/test instance နဲ့ recoverable data ပေါ်တွင် အရင်အတည်ပြုပါ။

လေ့ကျင့်ခန်း

Pure cache၊ session store၊ mixed workload သုံးမျိုးအတွက် policy recommendation နဲ့ reason ရေးပါ။

အလုပ်ဖြစ်ကြောင်း ဒီလိုသိမယ်: Configured ceiling၊ policy နှင့် eviction counters ကိုစစ်နိုင်မည်။

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

Maxmemory နှင့် Eviction Policies | Thuta Learning