Auto Scaling နဲ့ Load Balancer

Myanmar Version

ယနေ့ခေတ် ဒစ်ဂျစ်တယ်ကမ္ဘာမှာ သင့် website ဒါမှမဟုတ် web application တစ်ခု အောင်မြင်လာတဲ့အခါမှာ ရုတ်တရက် traffic များပြားလာတဲ့ ပြဿနာနဲ့ ရင်ဆိုင်ရနိုင်ပါတယ်။ ဥပမာအားဖြင့်၊ သင့်ရဲ့ website မှာ အထူးလျှော့စျေး အစီအစဉ်တစ်ခု ကြေညာလိုက်တဲ့အခါ၊ ပုံမှန် server တစ်ခုတည်းက အဲဒီ traffic ပမာဏကို ကိုင်တွယ်နိုင်စွမ်းမရှိဘဲ website ဟာ လေးလံလာနိုင်သလို ရပ်တန့်သွားတာမျိုးလည်း ဖြစ်နိုင်ပါတယ်။

ဒီလို ပြဿနာကို ဖြေရှင်းဖို့အတွက် AWS က Auto Scaling နဲ့ Elastic Load Balancing (ELB) လို ဝန်ဆောင်မှုတွေကို ပေးထားပါတယ်။ ဒီ post မှာတော့ ဒီဝန်ဆောင်မှုနှစ်ခုကို အသုံးပြုပြီး သင့်ရဲ့ website ကို ဘယ်လို လွယ်လွယ်ကူကူ၊ စရိတ်သက်သာစွာ၊ ခိုင်မာစွာ တည်ဆောက်နိုင်မလဲဆိုတာကို အသေးစိတ်လေ့လာသွားပါမယ်။

AWS Auto Scaling ဆိုတာ ဘာလဲ။

AWS Auto Scaling ဆိုတာ သင့် application ရဲ့ လိုအပ်ချက်ပေါ်မူတည်ပြီး EC2 instances အရေအတွက်ကို အလိုအလျောက် တိုးခြင်း (scale out) သို့မဟုတ် လျှော့ချခြင်း (scale in) လုပ်ပေးတဲ့ ဝန်ဆောင်မှုတစ်ခုဖြစ်ပါတယ်။ ဒါဟာ သင့် application ကို traffic များလာတဲ့အခါ server အသစ်တွေ အလိုအလျောက် ထပ်ထည့်ပေးပြီး၊ traffic နည်းသွားတဲ့အခါ အသုံးမလိုတော့တဲ့ server တွေကို ဖျက်သိမ်းပေးပါတယ်။

Auto Scaling ဘာကြောင့် အရေးကြီးတာလဲ။

  • ပြောင်းလွယ်ပြင်လွယ်ရှိခြင်း (Elasticity): သင့် application ကို တောင်းဆိုမှု (demand) ပေါ်မူတည်ပြီး အလိုအလျောက် ချိန်ညှိနိုင်တာကြောင့် website ရဲ့ စွမ်းဆောင်ရည်ကို အမြဲတမ်း ကောင်းမွန်အောင် ထိန်းထားနိုင်ပါတယ်။
  • ကုန်ကျစရိတ်သက်သာမှု (Cost Optimization): သင်လိုအပ်တဲ့ server တွေအတွက်သာ ပေးချေရတာကြောင့် server တွေကို အလဟသ ဖွင့်ထားရတဲ့ ကုန်ကျစရိတ်တွေကနေ လျှော့ချနိုင်ပါတယ်။
  • စိတ်ချရမှု (High Availability): သင့်ရဲ့ server တစ်ခုခုမှာ ပြဿနာဖြစ်ပြီး အလုပ်မလုပ်တော့ဘူးဆိုရင် Auto Scaling က အဲဒီ့ server ကို အလိုအလျောက် အသစ်တစ်ခုနဲ့ အစားထိုးပေးတာကြောင့် သင့် website ဟာ အမြဲတမ်းလည်ပတ်နေနိုင်မှာပါ။

Auto Scaling ရဲ့ အဓိက အစိတ်အပိုင်းများ

  1. Launch Template: ဒါဟာ Auto Scaling Group (ASG) က server အသစ်တွေကို စတင်တဲ့အခါ အသုံးပြုတဲ့ ပုံစံ (blueprint) ဖြစ်ပါတယ်။ Launch Template မှာ သင့်ရဲ့ EC2 instance (AMI, instance type, security group) တွေအတွက် အသေးစိတ်အချက်အလက်တွေ ပါဝင်ပါတယ်။
  2. Auto Scaling Group (ASG): ဒါက Auto Scaling က စီမံခန့်ခွဲတဲ့ EC2 instances တွေကို စုစည်းထားတဲ့ အုပ်စု တစ်ခုဖြစ်ပါတယ်။ ASG မှာ အရေးကြီးတဲ့ အပိုင်းသုံးခု ရှိပါတယ်။
    • Min Size: သင့် application အတွက် အမြဲတမ်းအလုပ်လုပ်နေရမယ့် အနိမ့်ဆုံး instances အရေအတွက်။
    • Max Size: traffic အများဆုံးဖြစ်တဲ့အခါမှာတောင် အလိုအလျောက်ချဲ့ထွင်နိုင်မယ့် အများဆုံး instances အရေအတွက်။
    • Desired Capacity: လက်ရှိအလုပ်လုပ်စေလိုတဲ့ instances အရေအတွက်။
  3. Scaling Policies: ဒါတွေက Auto Scaling Group ကို ဘယ်အချိန်မှာ ချဲ့ထွင် (scale out) ဒါမှမဟုတ် လျှော့ချ (scale in) ရမလဲဆိုတာကို ပြောပြတဲ့ စည်းမျဉ်းတွေ ဖြစ်ပါတယ်။
    • Target Tracking Scaling: ဒါဟာ အသုံးအများဆုံးနဲ့ အထိရောက်ဆုံး scaling policy ဖြစ်ပါတယ်။ ဥပမာအားဖြင့်၊ သင်ဟာ “ပျမ်းမျှ CPU အသုံးပြုမှု 70% မှာ ထိန်းထားပေးပါ” ဆိုတဲ့ စည်းမျဉ်းကို သတ်မှတ်နိုင်ပါတယ်။ CPU 70% ထက် ကျော်လွန်သွားတဲ့အခါ Auto Scaling က server အသစ်တွေ ထပ်ထည့်ပေးပြီး၊ 70% အောက်ကျသွားတဲ့အခါ server တွေကို လျှော့ချပေးပါတယ်။
    • Simple Scaling: ဒါကတော့ CloudWatch metric တစ်ခုရဲ့ တန်ဖိုး (ဥပမာ- CPU Utilization > 80%) ကို အခြေခံပြီး instances အရေအတွက်ကို တိုးခြင်း သို့မဟုတ် လျှော့ချခြင်း လုပ်ဆောင်ပါတယ်။

Elastic Load Balancing (ELB) ဆိုတာ ဘာလဲ။

Elastic Load Balancing ဆိုတာ သင့် website ကို ဝင်လာတဲ့ internet traffic ကို Auto Scaling Group မှာရှိတဲ့ server တွေဆီကို အချိုးကျ ခွဲဝေပေးတဲ့ ဝန်ဆောင်မှုတစ်ခုဖြစ်ပါတယ်။ ELB ဟာ ဝင်လာတဲ့ traffic ကို တစ်နေရာတည်းမှာ လက်ခံပြီး အလုပ်များတဲ့ server တွေကို အလုပ်မပေးဘဲ၊ အလုပ်အားနေတဲ့ server တွေကို ဦးစားပေး ခွဲဝေပေးပါတယ်။

ELB ဘာကြောင့် အရေးကြီးတာလဲ။

  • Traffic မျှဝေပေးခြင်း: server တစ်ခုတည်းကို traffic အားလုံး ပုံကျမလာအောင် တားဆီးပေးပါတယ်။
  • ကျန်းမာရေး စစ်ဆေးပေးခြင်း (Health Checks): ELB က သူ့နောက်ကွယ်မှာရှိတဲ့ server တွေရဲ့ ကျန်းမာရေးကို အမြဲစစ်ဆေးနေပါတယ်။ server တစ်ခုခုမှာ ပြဿနာဖြစ်နေရင် အဲဒီ့ server ဆီကို traffic ပို့တာကို ရပ်တန့်ပေးပြီး ကျန်တဲ့ ကျန်းမာတဲ့ server တွေဆီကိုပဲ ပို့ပေးပါတယ်။

Auto Scaling နဲ့ ELB ဘယ်လို အတူတကွ အလုပ်လုပ်သလဲ။ (Architecture)

သင့်ရဲ့ အလိုအလျောက်ချဲ့ထွင်နိုင်တဲ့ web server architecture ဟာ အောက်ပါအတိုင်း အလုပ်လုပ်ပါတယ်။

  1. အသုံးပြုသူ (Users): သုံးစွဲသူတွေဟာ သင့်ရဲ့ domain name ကို သုံးပြီး သင့် website ကို ဝင်ရောက်ပါတယ်။
  2. Load Balancer (ELB): DNS ကနေတဆင့် Traffic တွေဟာ ELB ကို ဦးစွာရောက်လာပါတယ်။
  3. Traffic ဖြန့်ဝေခြင်း: ELB က ဝင်လာတဲ့ traffic ကို Auto Scaling Group မှာရှိတဲ့ Load နည်းတဲ့ EC2 instances တွေဆီကို မျှမျှတတ ခွဲဝေပေးပါတယ်။
  4. Auto Scaling Group (ASG): ASG မှာရှိတဲ့ instances တွေရဲ့ CPU အသုံးပြုမှု၊ network traffic စတဲ့ အချက်အလက်တွေကို AWS CloudWatch ကနေ အမြဲတမ်း စောင့်ကြည့်နေပါတယ်။
  5. ချဲ့ထွင်ခြင်း (Scale Out): သတ်မှတ်ထားတဲ့ CPU utilization (ဥပမာ- 70%) ထက် ကျော်လွန်သွားတဲ့အခါ ASG က Launch Template ကို အသုံးပြုပြီး server အသစ်တစ်ခုကို အလိုအလျောက် စတင်ပေးပါတယ်။
  6. အသစ်ဝင်ရောက်ခြင်း: server အသစ်က စတင်အလုပ်လုပ်တဲ့အခါ ELB နဲ့ ချိတ်ဆက်ပြီး traffic ကို စတင်လက်ခံပါတယ်။
  7. လျှော့ချခြင်း (Scale In): traffic နည်းသွားပြီး CPU အသုံးပြုမှုက သတ်မှတ်ထားတဲ့ ရာခိုင်နှုန်းအောက် ရောက်သွားတဲ့အခါ ASG က အသုံးမလိုတော့တဲ့ instances တွေကို အလိုအလျောက် ဖျက်သိမ်းပေးပါတယ်။

နိဂုံး (MBA အမြင်)

စီးပွားရေးလုပ်ငန်းတစ်ခုရဲ့ရှုထောင့်ကနေကြည့်ရင် AWS Auto Scaling နဲ့ ELB တို့ဟာ ရိုးရှင်းတဲ့ နည်းပညာဝန်ဆောင်မှုတွေသက်သက်မဟုတ်ပါဘူး။ ဒါတွေဟာ

  • လုပ်ငန်းအပေါ် အားထားနိုင်မှု (Reliability): Website တွေ၊ application တွေ downtime မဖြစ်အောင် ကာကွယ်ပေးတဲ့ စနစ်တွေပါ။
  • လုပ်ငန်း တိုးတက်နိုင်စွမ်း (Scalability): လုပ်ငန်းလိုအပ်ချက်အပေါ်မူတည်ပြီး အကန့်အသတ်မရှိ ချဲ့ထွင်နိုင်စွမ်းကို ပေးစွမ်းပါတယ်။
  • ရင်းနှီးမြှုပ်နှံမှုအပေါ် အကျိုးအမြတ် (ROI): လိုအပ်တဲ့အချိန်မှာ လိုအပ်တဲ့ ပမာဏအတွက်သာ ပေးချေရတဲ့ စနစ်ကြောင့် IT ကုန်ကျစရိတ်တွေကို ထိရောက်စွာ စီမံခန့်ခွဲနိုင်ပြီး ရင်းနှီးမြှုပ်နှံမှု အပေါ် အကျိုးအမြတ်ကို တိုးတက်စေပါတယ်။

ဒီလို architecture ကို အသုံးပြုခြင်းဟာ သင့်ရဲ့ လုပ်ငန်းကို စိတ်ချရပြီး ခေတ်မီတဲ့ ဒစ်ဂျစ်တယ် စနစ်တစ်ခုအဖြစ် ပြောင်းလဲပေးနိုင်မှာပါ။ AWS Free Tier ကို အသုံးပြုပြီး သင့်ကိုယ်ပိုင် Auto Scaling နဲ့ ELB setup ကို စတင်တည်ဆောက်ကြည့်နိုင်ပါတယ်။


English Version

Building a Scalable Web Server on AWS: A Guide to Auto Scaling and Load Balancing

In today’s digital world, when your website or web application becomes successful, you’re likely to face the problem of sudden traffic spikes. For instance, when you announce a special promotion on your website, a single server might not be able to handle the traffic, leading to slow performance or even crashing the site.

To solve this problem, AWS provides services like Auto Scaling and Elastic Load Balancing (ELB). In this post, we will explore in detail how to use these two services to build a resilient, cost-effective, and highly scalable website.

What is AWS Auto Scaling?

AWS Auto Scaling is a service that automatically adds or removes EC2 instances based on the demand for your application. It automatically adds new servers when traffic increases and removes unnecessary servers when traffic decreases.

Why is Auto Scaling Important?

  • Elasticity: It allows your application to automatically adjust to demand, ensuring your website’s performance remains consistent.
  • Cost Optimization: You only pay for the servers you need at any given moment, eliminating the costs associated with idle servers.
  • High Availability: If one of your servers fails and becomes unhealthy, Auto Scaling automatically replaces it with a new one, ensuring your website stays online.

Key Components of Auto Scaling

  1. Launch Template: This is the blueprint that an Auto Scaling Group (ASG) uses to launch new servers. The Launch Template contains all the details for your new EC2 instance, such as the AMI, instance type, and security group.
  2. Auto Scaling Group (ASG): This is a collection of EC2 instances that Auto Scaling manages. An ASG has three important settings:
    • Min Size: The minimum number of instances you want running at all times for your application.
    • Max Size: The maximum number of instances you allow the group to scale out to during peak traffic.
    • Desired Capacity: The current target number of instances you want to be running.
  3. Scaling Policies: These are the rules that tell the Auto Scaling Group when to scale out or scale in.
    • Target Tracking Scaling: This is the most common and effective scaling policy. For example, you can set a rule that says, “Maintain the average CPU utilization at 70%.” When the CPU goes above 70%, Auto Scaling adds more servers. When it falls below, it removes servers.
    • Simple Scaling: This policy adds or removes a specific number of instances based on a single CloudWatch metric value (e.g., if CPU Utilization > 80%).

What is Elastic Load Balancing (ELB)?

Elastic Load Balancing is a service that automatically distributes incoming internet traffic to your website across the servers in your Auto Scaling Group. ELB acts as a single point of contact for all incoming traffic and directs it to the healthy servers, preventing any single server from being overwhelmed.

Why is ELB Important?

  • Traffic Distribution: It prevents all incoming traffic from hitting a single server.
  • Health Checks: ELB constantly monitors the health of the servers behind it. If a server becomes unhealthy, ELB stops sending traffic to it and redirects all traffic to the remaining healthy servers.

How They Work Together (The Architecture)

Your highly scalable web server architecture works as follows.

  1. Users: Visitors access your website using your domain name.
  2. Load Balancer (ELB): The DNS directs all incoming traffic to your ELB.
  3. Traffic Distribution: The ELB distributes the incoming traffic evenly among the healthy EC2 instances in your Auto Scaling Group.
  4. Auto Scaling Group (ASG): The ASG, with the help of AWS CloudWatch, continuously monitors metrics like CPU utilization or network traffic on its instances.
  5. Scale Out: When the defined CPU utilization (e.g., 70%) is exceeded, the ASG automatically launches a new server using the Launch Template.
  6. Join the Group: When the new server starts, it registers with the ELB and begins receiving traffic.
  7. Scale In: When traffic decreases and the CPU utilization falls below the threshold, the ASG automatically terminates the unnecessary instances, saving you money.

Conclusion (An MBA Perspective)

From a business standpoint, AWS Auto Scaling and ELB are not just simple technical services. They are key enablers of:

  • Business Reliability: They ensure your websites and applications don’t experience downtime, protecting your brand reputation and revenue.
  • Business Scalability: They provide the ability to scale to meet unpredictable demand, allowing you to grow your business without worrying about infrastructure limits.
  • Return on Investment (ROI): The pay-for-what-you-use model allows for efficient management of IT costs, leading to a better return on your technology investments.

Adopting this architecture is a crucial step in transforming your business into a modern, reliable, and scalable digital operation. You can start building your own Auto Scaling and ELB setup using the AWS Free Tier.


Scroll to Top
Share via
Copy link