Thuta Learning
ရှာဖွေရန်
Redis
AdvancedData & Databasesbeginner

Redis Cluster နှင့် Hash Slots

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

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

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

Redis Cluster က keyspace ကို 16,384 hash slots ခွဲပြီး primary nodes များကြား distribute လုပ်ပါတယ်။ Client က MOVED/ASK redirects နားလည်ရပါတယ်။ Multi-key command/script keys များ same slot ဖြစ်ရန် `{...}` hash tag သုံးနိုင်သော်လည်း tag အလွန်ကျယ်ရင် hot shard ဖြစ်နိုင်ပါတယ်။ Cluster က horizontal capacity ပေးသော်လည်း operations complexity တိုးပါတယ်။

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

Coupon script keys ကို `coupon:{42}:remaining` နဲ့ `coupon:{42}:claims` လုပ်ပြီး same slot ထားမယ်။ `CLUSTER KEYSLOT` နဲ့စစ်၊ node/slot health monitor၊ rolling maintenance နဲ့ reshard test လုပ်မယ်။ Dataset/throughput တစ် node capacity မကျော်သေးလျှင် Sentinel deployment ကိုပဲရွေးနိုင်ပါတယ်။

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

shell
CLUSTER INFO
CLUSTER NODES
CLUSTER SLOTS
CLUSTER KEYSLOT coupon:{42}:remaining
CLUSTER KEYSLOT coupon:{42}:claims
CLUSTER COUNTKEYSINSLOT 9030
You should see
Cluster health၊ node ownership နဲ့ related keys slot တူကြောင်းစစ်နိုင်မည်။

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

Tenant hash tag strategy တစ်ခုရေးပြီး noisy tenant hotspot ဖြစ်နိုင်ပုံနဲ့ mitigation ရေးပါ။

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

Hash tag ကို `{tenant}` တစ်ခုတည်းဖြင့် tenant ကြီးတစ်ခုရဲ့ keys အားလုံးပေါင်းမထားပါနှင့်။ Sharding benefit ပျောက်နိုင်ပါတယ်။

Redis — Cluster SpecificationRedis

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

  • Hash tag ကို `{tenant}` တစ်ခုတည်းဖြင့် tenant ကြီးတစ်ခုရဲ့ keys အားလုံးပေါင်းမထားပါနှင့်။ Sharding benefit ပျောက်နိုင်ပါတယ်။
  • နမူနာ command ကို production Redis ပေါ် တိုက်ရိုက်မစမ်းဘဲ local/test instance နဲ့ recoverable data ပေါ်တွင် အရင်အတည်ပြုပါ။

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

Tenant hash tag strategy တစ်ခုရေးပြီး noisy tenant hotspot ဖြစ်နိုင်ပုံနဲ့ mitigation ရေးပါ။

You'll know it worked when: Cluster health၊ node ownership နဲ့ related keys slot တူကြောင်းစစ်နိုင်မည်။

Redis Cluster နှင့် Hash Slots | Thuta Learning