관리 메뉴

진취적 삶

섹션8 고가용성 및 스케일링성:ELB 및 ASG 본문

AWS SAA

섹션8 고가용성 및 스케일링성:ELB 및 ASG

hp0724 2023. 7. 15. 20:32

Scalability

  • applicaiton / system can handle greater loads by adapting
  • two kinds of scalability
    • vertical scalability
    • horizontal scalability

vertical scalability

인스턴스의 크기를 확장하는것을 의미

t2.micro → t2.large 바꾸는거랑 같은 느낌

horizontal scalability

애플리케이션에서 인스턴스나 시스템의 수를 늘리는 방법

high availabiity

애플리케이션 또는 시스템을 적어도 둘 이상의 aws의 az나 데이터 센터에서 가동 중이라는걸 의미

run instances for the same application across multi AZ

스케일 아웃 :인스턴스 수가 늘어나면

스케일 인 : 인스턴스 수가 줄어들면

load balancing

  • load balances are servers that forward traffic to multiple servers downstram
  • spread load across multiple downstream instances
  • handle failures of downstream instances
  • 인스턴스의 정기적 체크가능
  • health checks는 port 와 route 에 의해 이루어짐
  • ELB는 애플리케이션에 사용 가능한 정적 DNS 이름 제공

Application Load Balancer

the application servers don’t see the IP of the client directly

  • the treu IP of the client is inserted in the header X-Forwarded-for

하나의 URL 로 두 EC2 인스턴스에 접속

HTTP 와 HTTPS 타입의 트래픽을 위한것 (layer 7 )

security group에 Inbound rules 에 http 를 securiy groupd 적용시키기

ALB을 사용하여 EC2 인스턴스에 트래픽을 배분하는 경우 , 요청을 받게되는 IP주소는

ALB의 사설 IP주소가 된다. 클라이언트의 IP주소를 받기 위해 ,ALB는 클라이언트의 IP주소를 포함하고 있는 X-Forward-for라는 헤더를 추가해야 한다.

URL경로, 호스트 이름 ,HTTP 헤더 및 쿼리 문자열 기반으로 라우팅

Network Load Balancer

tcp 와 udp 트래픽을 다룬다. (layer 4)

NLB has one static IP per AZ and supports assigning Elastic IP

고성능 ,TCP ,UDP ,정적 IP 가 나오면 NLB

TCP , HTTPS 및 HTTP 상태 확인 지원

Gateway Load Balancer

  • operates at Layer 3 (Network layer) - IP Packets
  • Transparent Network Gateway -single entry/ exit for all traffic
  • Load Balancer - distributes traffic to your virtual appliances

Uses the GENEVE protocol on port 6081

Sticky Sessions (Session Affinity)

same client is always redirected to the same instance behind a load balancer

ELB 고정 세션 기능은 동일한 클라이언트에 대한 트래픽이 항상 동일한 대상으로 리다이렉트 하도록 해준다.

application -based cookies

  • custom cookie
    • generated by the target
  • application cookie
    • generated by the load balancer
    • cookie name is AWSALBAPP

Duration-based cookies

  • cookie generated by the load balancer
  • cookie name is AWSALB for ALB , AWSELB for CLB

Cross -Zone Load Balancing

모든 영역에 있는 EC2 인스턴스에 트래픽이 고르게 분배된다.

SSL/TLS 인증서

SSL: 클라이언트와 로드 밸러서 사이에서 트래픽이 이동하는 동안 암호화해준다.

SSL : Secure Sockets Layer , used to encrypt connections

TLS : refers to Transport Layer Security , which is a newer version

만료 날짜가 있어서 주기적으로 갱신해야 한다.

Server Name Indication (SNI)

  • 여러개의 SSL 인증서를 하나의 웹서버에 로드해 하나의 웹 서버가 여러개의 웹 사이트 지원하도록 함
  • 클라이언트가 대상 서버의 호스트 이름을 지정하도록 한다.
  • Only works ALB & NLB ,CloudFront

Connection Draining

  • Deregistration Delay
  • 인스턴스가 등록 취소, 혹은 비정상인 상태에 있을때 인스턴스에 시간을 주어 활성 요청을 완료하도록 하는 것

Auto Scaling Group

증가한 로드에 맞추어서 scale out( ec2 인스턴스 개수 증가)

감소한 로드에 맞추어서 scale in (ec2 인스턴스 개수 제거)

min ,max 설정 가능

CloudWatch alarm 이 지표를 보고 알람을 울려 auto scaling 작동시킨다

EC2 인스턴스의 상태를 판단해서 비정상인경우 EC2 인스턴스를 종료 시키고

새로운 EC2 인스턴스 실행

Dynamic Scaling Policies

  • Target Tracking Scaling

    • most simple and easy to set-up
  • simple /step scaling

    • when a cloudWatch alarm is triggered (CPU > 70%) then add 2 units
    • when a cloudWatch alarm is triggered(CPU < 30%) then remove 1
  • Scheduled Actions

    스케줄에 맞춰서 증가 감소