[AWS Practice] 8. Elastic Load Balancing & Auto Scaling Groups Section

Sunwu Park·2024년 2월 25일
0

AWS-Study

목록 보기
10/17

Scalability

  • Scalability: application.system can handle greater loads by adapting

Types:
- Vertical Scalability
increasing size of instance (t2.micro -> t2.large, hardware limit)
- Horizontal Scalability (elsticity)
increasing number of instances/ systems for your application
easy to horizontally scale

High Availability

  • hand in hand with horizontal scaling
  • at least 2 AZ -> survive data center loss

Scalability vs Elasticity vs Agility

  • Scalability: ability to accommodate a larger load by making the hardware stronger(scale up) or adding nodes (scale out)
  • Elasticity: auto-scaling -> so that system can scale based on the laod. cloud-friendly: pay-per-use, match demand, optimize costs
  • Agility: new IT resources are only a click away, reduce the time to make those resources available to ur developers from weeks to just minutes.

What is Load Balancing?

  • Load balancers are servers that forward internet traffic to multiple servers downstream
    - Spread load
    • expose single point of access(dns)
    • seamlessly handle failures of downstream instances
    • regular health check
    • provide ssl termination

Why use an Elastic Load Balancer?

  • ELB is managed load balancer
    - AWS guarantees that it will be working, taking care of upgrades, maintenance, high availability..

  • cost less to setup own load balancer but it will be a lot more effort on your end

  • 4 kinds of load balancers offered by AWS:
    - Application Load Balancer(HTTP/HTTPS only) - Layer 7

    • Network Load Balancer(allows TCP) - Layer 4
    • Gateway Load Balancer - Layer 3
    • Classic Load Balancer - Layer 4 & 7(Retired)

EXERCISE

Application Load Balancer

EC2 Target Group 생성

인스턴스들 Target에 추가

로드 밸런서 생성해준다

DNS 주소로 접속을 했을때


=> ip주소가 번갈아 가면서 나온다. EC2 인스턴스 사이에 리디렉션하기 때문이다. => 부하 분산이 일어난다는 증거이다.

What is Auto Scaling Group?

=> An Auto Scaling Group (ASG) is a feature provided by AWS that allows you to automatically adjust the number of EC2 instances in your application's fleet based on the current demand. It helps you maintain the desired level of application availability, performance, and cost optimization.

  • Scale out (add EC2 instances) to match an increased load
    • Scale in (remove EC2 instances) to match a decreased load
    • Ensure we have a minimum and a maximum number of machines running
    • Automatically register new instances to a load balancer
    • Replace unhealthy instances
    • Cost Savings: only run at an optimal capacity (principle of the cloud)

Auto Scaling Group 만들기

템플릿을 만든다

-> ASG 어떻게 인스턴스 만드는지 알려준다 -> EC2 만드는 것과 비슷함

템플릿을 ASG에 적용한다

VPC, AZ 설정

로드 밸런싱 설정하기

=> 자동 스캐닝 그룹 (ASG)을 사용하여 ALB (Application Load Balancer)를 위한 데모 타깃 그룹에 생성된 모든 인스턴스를 등록해야 합니다. ASG는 인스턴스의 수평적인 확장과 관리를 자동화하는 기능을 제공합니다.

그룹사이즈, scaling policy

타겟그룹을 보면 두개가 만들어진것을 확인할 수 있다

Desired Capacity를 2로 설정했기 때문에 하나를 종료하면 자동으로 하나가 실행이 된다

Auto Scaling Groups - Scalinig Strategies

  • Manual Scaling : Update size manually

  • Dynamic Scaling:
    Simple/Step Scaling
    - When a CloudWatch alarm is triggered (example CPU > 70%), then add 2 units
    Target Tracking Scaling
    - average ASG CPU to stay at around 40%
    Scheduled Scaling
    - Anticipate a scaling based on known usage patterns
    • Example: increase the min. capacity to 10 at 5 pm on Fridays

  • Predictive Scaling
    - USE Machine Learning to predict future traffic ahead of time
    - Automatically provisions the right number of EC2 instances in advance

  • When ur load has predictable time-based patterns

Quesitons

0개의 댓글