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