<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Untitled Publication]]></title><description><![CDATA[Untitled Publication]]></description><link>https://myatminsoe.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 13:21:40 GMT</lastBuildDate><atom:link href="https://myatminsoe.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to work with Cluster Mode on Amazon Elasticache for Redis]]></title><description><![CDATA[Redis ရဲ့ အရှည်ကတော့ Remote Dictionary Server ဖြစ်ပြီး NoSQL Database ဒါမှမဟုတ် In-Memory Database (IMDB) လို့သိကြပါတယ်။ များသောအားဖြင့် Redis ကို Database ရဲ့ Load ကိုသက်သာစေရန် Data Caching နဲ့ Session Store လုပ်ခြင်းတို့အတွက်သုံးစွဲကြပါတယ်။ Redis ...]]></description><link>https://myatminsoe.hashnode.dev/how-to-work-with-cluster-mode-on-amazon-elasticache-for-redis</link><guid isPermaLink="true">https://myatminsoe.hashnode.dev/how-to-work-with-cluster-mode-on-amazon-elasticache-for-redis</guid><category><![CDATA[AWS]]></category><dc:creator><![CDATA[Myat Min Soe]]></dc:creator><pubDate>Tue, 30 May 2023 17:20:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1685466682292/1361b02c-68f3-40d6-9516-17445331b135.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Redis ရဲ့ အရှည်ကတော့ Remote Dictionary Server ဖြစ်ပြီး NoSQL Database ဒါမှမဟုတ် In-Memory Database (IMDB) လို့သိကြပါတယ်။ များသောအားဖြင့် Redis ကို Database ရဲ့ Load ကိုသက်သာစေရန် Data Caching နဲ့ Session Store လုပ်ခြင်းတို့အတွက်သုံးစွဲကြပါတယ်။ Redis ဟာ Memory ပေါ်မှာ Data ကို Key Value ပုံစံနဲ့သိမ်းတဲ့အတွက် အရမ်းကိုမြန်ပါတယ်။Redis ကိုအခြားအသုံးပြု့တဲ့ပုံစံအများကြီးရှိကြပါတယ်။ Chat, Messaging, Queue, Real-time Analysis နဲ့ Machine Learning တွေအတွက်လည်း သုံးစွဲကြပါတယ်။</p>
<p>Redis ကို App တစ်ခု့အတွက်စတင်သုံးချိန်မှာ Server Size လည်းအများကြီးမလိုပါဘူး။ ဒီအတိုင်းပဲသုံးလိုက်တော့မယ်ဆိုပြီး Single Node တွေထားကြမိတာများပါတယ်။ဒါပေမဲ့ Application သုံးစွဲမှုက တဖြည်းဖြည်းတိုးလာတဲ့ အခါကြရင်တော့ လုပ်ငန်းလိုအပ်ချက်ကြောင့် Redis Node ရဲ့ Resource တွေဖြစ်တဲ့ CPU, Memory တွေကိုမဖြစ်မနေတိုးလာရပါတော့မယ်။</p>
<p>ဒီလိုတိုးရတော့မဲ့အခြေအနေမှာ Approaches က နှစ်မျိုးရှိပါတယ်။ အားလုံးကြားဖူးကြမဲ့ Horizontal Scaling နဲ့ Vertical Scaling ပါ။</p>
<p>Vertical Scaling (or) Scale Up ကတော့ လက်ရှိ Server ကို CPU, Memory, Storage တွေ များများပိုသုံးလိုက်တာဖြစ်ပြီး Horizontal Scaling (or) Scale Out ကတော့ နဂိုရှိပြီးသား Server ကိုထားပြီး နောက်ထပ် Server များစွာ ထပ်ထည့်လိုက်တာမျိုးဖြစ်ပါတယ်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685461793337/665fe25e-c955-4570-b4d5-1206df2ebc9d.png" alt class="image--center mx-auto" /></p>
<p>ဒီအချိန်မှာ ဘာ Service အတွက်အဓိက အသုံးပြု့မှာလည်းကို ပြန်စဥ်းစားရပါမယ်။  အသုံးပြု့မဲ့ Service ပေါ်မူတည်ပြီး Scaling လုပ်ရမဲ့ ပုံစံ ကွာခြားသွားမှာဖြစ်ပါတယ်။ Redis Engine ဟာ Version 6 ကနေစပြီး Multi Thread ဖြစ်သွားပေမဲ့ Server ရဲ့ Resource တွေကိုပဲ ထပ်မြှင့်ပေးလိုက်တာဟာကောင်းမွန်တဲ့နည်းလမ်းတစ်ခု့လို့ပြောလို့မရပါဘူး။ Limit တစ်ခု့ရောက်ရင် ဒါဟာ ရပ်သွားမှာဖြစ်ပါတယ်။ မြင်သာထင်သာရှိအောင် Server ကို Node လို့သုံးလိုက်ပါမယ်။ ဒါပေမဲ့ Node အများကြီးထားလိုက်မယ် ဝင်လာတဲ့ Data Set တွေကို Node အများကြီးမှာခွဲသိမ်းမယ်ဆိုရင်တော့ ပြန်ယူတဲ့ အခါကျလျင်လည်း Node အများကြီးကနေ ပြန်ယူမှာဖြစ် ပြီး ဝင်လာတဲ့ Data Set တွေကိုလည်း Shards တစ်ခု့ခြင်းစီရဲ့ Hash Slots တွေမှာ Key နဲ့ Map လုပ်ပြီးခွဲ သိမ်းပေးခြင်းဖြင့် Data တွေဟာ Shards (Node) တစ်ခု့တည်းမှာ စု့မနေတော့ပဲ Node ရဲ့စွမ်းဆောင်ရည်ကို ပိုကောင်းလာစေမှာဖြစ်ပါတယ်။ Hash Slots အကြောင်းကိုတော့ Labs မှာရှင်းပြသွားပါမယ်။</p>
<p>ဒီ Labs လေးမှာတော့ AWS ရဲ့ ElastiCache for Redis ဆိုတဲ့ Service ရဲ့ Cluster Mode ကို ဘယ်လို အသုံးပြု့သွားနိုင်မလဲကို ဖော်ပြပေးသွားပါမယ်။</p>
<p>ElastiCache Redis မှာ Cluster Mode 2 မျိုးတွေ့ရပါတယ်။</p>
<p>Cluster Mode Disabled</p>
<p>Cluster Mode Enabled</p>
<p>ဖြစ်ပါတယ်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685465624642/1c490d99-f401-4eaa-b52f-7575f4f5a031.png" alt class="image--center mx-auto" /></p>
<p>Cluster Disabled Mode မှာတော့ Primary Node တစ်လုံးထဲသာထားနိုင်ပြီး Failover အတွက် Replica တွေထားသုံးတဲ့ သဘောမျိုးဖြစ်ပြီး Up to 5 Replica ထိ ထားနိုင်ပါတယ်။ ဒါက လုံးဝကို Maximum ဖြစ်ပါတယ်။ Primary 1 လုံးမှာ Replica 5 လုံးကနေ ပိုတိုးလို့မရတော့ပါဘူး။ Primary Node နဲ့ Replica ဟာ Sync ဖြစ်နေမှာဖြစ်ပြီး Replica ရှိတဲ့ အတွက် Primary Node Failure ဖြစ်သွာရင်တော့ Replica ဟာ Primary အဖြစ် Auto Promote ဖြစ်သွားမှာဖြစ်ပါတယ်။</p>
<p>Disabled Mode မှာ Horizontal Scaling လုပ်မယ်ဆို လျင်လည်း Replica တွေကိုမူလက 1 လုံးသာထားခဲ့လျှင် Up to 5 Replica ထိ ထားနိုင်မှာဖြစ်ပြီး Primary Node ကို Horizonal Scaling လုပ်လို့ရမှာမဟုတ်ပါဘူး။ Primary Node ကို Vertical Scaling ဖြစ်တဲ့ Server ရဲ့ Resource ကိုသာ မြှင့်ပေးလို့ရမှာဖြစ်ပါတယ်။</p>
<p>Failover ရှိအောင်ရော Scalability ရှိအောင်သုံးချင်ရင်တော့ Cluster Enabled Mode သုံးခြင်းကအကောင်းဆုံးဖြစ်ပါတယ်။ Cluster Enabled Mode သုံးခြင်းဖြင့် Cluster ကို Shards (Primary Node) များစွာ ခွဲနိုင်ပြီး Data Set တွေကို Partition ခွဲကာ Shards များအတွင်းသိမ်းဆည်းနိုင်ပါတယ်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685461825970/72208765-9534-4f88-8130-3f8c791aaf1a.png" alt class="image--center mx-auto" /></p>
<p>ဆိုကြပါစို့</p>
<p>Cluster Enabled Mode မှာ</p>
<p>Node Type = cache.r6g.xlarge</p>
<p>Shards = 3</p>
<p>Replica = 2</p>
<p>သုံးထားခြင်းဖြင့်</p>
<p>Cluster ထဲမှာ Primary Node 3 လုံး Primary တစ်လုံးအတွက် Replica 2 လုံး နှုန်းနဲ့ Replica 6 လုံး စု့စု့ပေါင်း 9 လုံး ရှိနေမှာဖြစ်ပါတယ်။ Redis တစ်ခု့တည်းအတွက်နဲ့ ဒီလောက်သုံးရမလားဆိုလျှင်တော့ System ရဲ့ လိုအပ်ချက်နဲ့ အရေးကြီးမှု့ပေါ် မူတည်ပြီးထားနိုင်ပါတယ်။</p>
<p>Cluster Enable Mode မှာ Shard (Primary Node) တွေကို Horizontal Scaling လုပ်လို့ရခြင်းက အဓိက သုံးသင့်တဲ့အချက်ဖြစ်ပြီး Cluster Disable Mode မှာတော့ Primary Node 1 လုံးသာထားလို့ရမှာဖြစ်ပါတယ်။</p>
<p>Labs</p>
<p>AWS Console ထဲရှိ Search မှ ElastiCache ဟု့ရိုက်ကာ ElastiCache ရဲ့ Console ဆီသွားပါမယ်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685461873564/a6c7287e-9a21-4f07-be2f-aa062e4525b4.png" alt class="image--center mx-auto" /></p>
<p>Redis နဲ့ Cluster ဖွဲ့မလား Memcached နဲ့ Cluster ဖွဲ့မလား ရွေးပါမယ်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685461892145/d6baad25-f748-4005-b68e-4eec9e5b72d6.png" alt class="image--center mx-auto" /></p>
<p>Cluster အသစ်ကို Enabled Mode နဲ့ဆောက်မယ်လို့ရွေးပါမယ်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685461908195/13266140-3b26-4ca0-aff4-085d5aaff106.png" alt class="image--center mx-auto" /></p>
<p>Cluster Name ပေးပါမယ်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685461932412/27add633-87c9-48cf-8c1e-aff13b5b986b.png" alt class="image--center mx-auto" /></p>
<p>Cluster Setting ထဲမှာ Redis Engine ကို Version ဘယ်လောက်ထားမလဲ Node Type ဘာထားမလဲ Cluster အတွင်းမှာ ရွေး ထားတဲ့ Node Type နဲ့ Shards ဘယ်နှစ်ခု့ Shard တစ်ခု့မှာ Replica ဘယ်နှစ်လုံးထားမလဲရွေးပါမယ်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685461951505/f3c3c754-58a6-40b8-9d10-8697134f0943.png" alt class="image--center mx-auto" /></p>
<p>Subnet Group တစ်ခု့ဆောက်ပြီး ဘယ် Subnet တွေသုံးလဲရွေးပါမယ်။ AZ မတူတဲ့ Subnet တွေကိုရွေးပြီး Group ထဲထားတာ Multi-AZ Hight Availability အတွက် ပိုကောင်းတဲ့ ရွေးချယ်မှုဖြစ်ပါတယ်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685461969555/93e4981d-7949-42ea-8786-4aa2e230dd59.png" alt class="image--center mx-auto" /></p>
<p>Slots and keyspaces ဆိုတာ Data သိမ်းဆည်းနိုင်တဲ့ နေရာတစ်ခု့ဖြစ်ပြီး Cluster တစ်ခု့မှာ Hash Slots 16,384 ခု့ရှိပြီး Equal Distribution ဆိုလျှင် Shards တိုင်းမှာ အညီအမျှ Hash Slots တွေကို ခွဲဝေထားမည်လို့ပြောခြင်းဖြစ်ပါတယ်။</p>
<p>ဥပမာအားဖြင့် Slots 9000 ရှိပြီး Shards 3 ခု့ရှိသည် ဆိုပါက Shards တစ်ခု့ စီတွင် Slots 3000 စီထားရှိမည်ဖြစ်ပြီး ဝင်လာတဲ့ Data Set များကိုခွဲကာ Key ဖြင့် Map လုပ်ပြီး Slots တစ်ခု့ခြင်းစီတွင်သိမ်းဆည်းမည်ဖြစ်ပြီး Slots တစ်ခြင်းစီတွင် Key များစွာ သိမ်းဆည်း နိုင်ပြီး Key Tags ဖြင့်ခွဲခြားမှတ်ထားမည်ဖြစ်ပါသည်။</p>
<p>Availability Zone placements မှာ Specify Availability Zones ထားခြင်းဖြင့် Shards နဲ့ Replica တွေကို AZ မတူအောင်ထားပေးပြီးFailure State တစ်ခု့ခု့ဖြစ်ခြင်းမှ ရှောင်လွှဲနိုင်မှာဖြစ်ပါတယ်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685461986681/aa683f91-07b0-46b6-ad47-06b34c1b3740.png" alt class="image--center mx-auto" /></p>
<p>Security Option မှာတော့ Encryption တွေကို ကျော်သွားပါမယ်။ အသုံးပြု့မယ်ဆိုလျှင်တော့ Encryption at rest အတွက် AWS KMS Service နှင့် Encryption in transit အတွက် Authentication တစ်မျိုးမျိုးကိုသုံးနိုင်ပါတယ်။</p>
<p>အဓိကအနေဖြင့် Security Group မှာ Port 6379 ကို Allow လုပ်မည့် Rule တစ်ခု့ကို မိမိ တို့၏ Compliance နှင့်ကိုက်ညီမည့်ပုံစံတစ်ခု့နှင့် ဆောက်ပေးရပါမည်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685462006562/066decf7-7da9-4154-bd72-b07ea5e6e6e9.png" alt class="image--center mx-auto" /></p>
<p>Maintenance window တွင် Labs ဖြစ်သည့်အတွက် No preference ဖြင့်ထားပါမည်။ အားလုံးသေချာပြီဆိုလျှင် Create ကိုနိုပ်ကာ Cluster တစ်ခု့ဆောက်ယူနိုင်ပါသည်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685462022037/a532410c-b03d-4eb5-84cf-b86c9cadfe79.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685463404863/a0d5735e-0d4a-41ae-9191-ff2178ee5839.png" alt class="image--center mx-auto" /></p>
<p>Redis Cluster တစ်ခု့ Create လုပ်နေသည်ကိုမြင်ရပါမည်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685462053569/47770a35-ac2a-45ff-8ed1-4ee6afd5f05e.png" alt class="image--center mx-auto" /></p>
<p>Clustet create ပြီးသွားသောအခါ Nodes 9 လုံးရှိနေသည်ကိုမြင်တွေ့ရမည်ဖြစ်ပြီး 3 လုံးမှာ Primary ဖြစ်ကာ 6 လုံးမှာ Replica ဖြစ်ပါသည်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685462068950/b397b9fc-5d56-436f-ac95-e6872464cfe1.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685462084945/3e71eb0f-4a83-4416-a754-071fedce9ee5.png" alt class="image--center mx-auto" /></p>
<p>Add Shards ကိုနိုပ်ကာ လိုသလောက် Shards အရေအတွက်ကို Redis Engine 5.0.6 နှင့်အထက်မှ စကာ (500) ထိ တိုးယူနိုင်ပါသည်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685464530079/52ed4691-1a6c-4ea0-84c3-45b4e162029e.png" alt class="image--center mx-auto" /></p>
<p>ဆောက်ထားသော Cluster ကို Redis-CLI မှ တဆင့် စမ်းကြည့်ပါမယ်။</p>
<p>Redis-CLI ကို ယခု့ ဖော်ပြထားသော command မှ တဆင့်သွင်းယူနိုင်ပါတယ်။</p>
<pre><code class="lang-bash"><span class="hljs-comment">#sudo apt install redis-server -y</span>
</code></pre>
<p>Service သွင်းယူပြီးလျှင်</p>
<p>redis-cli -h (Configurstion Endpoint) -p (Redis Port 6379)</p>
<p>ကိုရိုက်ကာစမ်းကြည့်နိုင်ပါသည်။</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1685464550852/df87104c-611b-4dba-97ee-464dfa4048c3.png" alt class="image--center mx-auto" /></p>
<p>****************************************************************************</p>
]]></content:encoded></item></channel></rss>