본문 바로가기

Cloud/AWS

ELB - Elastic Load Balancer

Elastic Load Balancer에는 3가지 종류가 있다.

  • Classic Load Balancer (다른 Load Balancer를 설명하도록 하겠다)
  • Network Load Balancer (L4 Load Balancer) - 공식 설명서
  • Application Load Balancer (L7 Load Balancer) - 공식 설명서

 

1. Network Load Balancer

  • 리스너 : Health Check를 하는방식
    • Protocols: TCP, TLS, UDP, TCP_UDP
    • Ports: 1-65535
  • Troubleshooting
    • A registered target is not in service
      • 대상이 InService 상태로 들어가는 데 예상보다 시간이 오래 걸릴 경우  
      • 보안 그룹이 트래픽을 허용하는지 또는 ACL이 걸려있는지 확인
    • Requests are not routed to targets
      • 보안 그룹이 트래픽을 허용하지 않음
      • ACL이 트래픽을 허용하지 않음
      • 대상이 활성화 되지 않는 가용 영역에 있음
      • 인스턴스가 피어링된 VPC에 속해 있음
    • Targets receive more health check requests than expected
      • 설정보다 많은 Healthcheck를 받았을 시
    • Targets receive fewer health check requests than expected
      • 설정보다 적은 Healthcheck를 받았을 시
      • net.ipv4.tcp_tw_recycle이 활성화 되었는지 확인
        (net.ipv4.tcp_tw_reuse 설정이 더 안전한 대안)
    • Unhealthy targets receive requests from the load balancer
      • 비정상 상태의 대상만 등록되어 Request가 비정상 상태의 대상으로 전달됨
    • Target fails HTTP or HTTPS health checks due to host header mismatch
      • 대상의 IP주소 및 상태 확인 포트 대신 로드 밸런서 노드의 IP 주소 및 리스너 포트가 포함됩니다. 호스트 헤더별로 수신 요청을 매핑하는 경우 상태확인이 HTTP 호스트 헤더와 일치하는지 확인해야한다.
    • Connections time out for requests from a target to its load balancer
      • 인스턴스 ID로 대상이 등록되는 내부 로드 밸런서가 있는지 확인합니다.
    • Performance decreases when moving targets to a Network Load Balancer
      • Classic Load Balancer와 Application Load Balancer는 모두 연결 멀티플렉싱을 사용하지만 Network Load Balancer는 그렇지 않습니다. 그러므로 대상이 Network Load Balancer 뒤에서 더 많은 TCP 연결을 수신할 수 있습니다. 대상이 수신할 수 있는 연결 요청 볼륨을 처리할 준비가 되었는지 확인하십시오
    • Port allocation errors connecting through AWS PrivateLink
      • 너무 많은 연결이 발생해 포트 할당 오류가 발생함
      • VPC 엔드포인트 서비스에 연결된 경우 Network Load Balancer는 각각의 고유 대상(IP 주소 및 포트)에 대해 55,000건의 동시 연결 또는 분당 약 55,000건의 연결을 지원합니다. 연결 건수가 이보다 더 많을 경우, 포트 할당 오류가 발생할 가능성이 증가합니다. 포트 할당 오류를 수정하려면 대상 그룹에 더 많은 대상을 추가합 니다.

 

2. Application Load Balancer

  • 라우팅 알고리즘 : Round Robin(라운드 로빈) or Least Outstanding Requests(최소 미해결 요청)
  • HTTP 400 : Bad Request
    • The client sent a malformed request that does not meet the HTTP specification.
    • The request header exceeded 16K per request line, 16K per single header, or 64K for the entire header.
  • HTTP 401 : Unauthorized 
    • 사용자를 인증하도록 리스너 규칙을 구성했습니다. 인증되지 않은 사용자를 거부하도록 OnUnauthenticatedRequest를 구성했거나 IdP가 액세스를 거부했습니다.
  • HTTP 403: Forbidden
    • Application Load Balancer에 대한 요청을 모니터링하기 위해 AWS WAF 웹 액세스 제어 목록(웹 ACL)을 구 성하여 요청이 차단되었습니다.
  • HTTP 405: Method not allowed
    • 클라이언트가 사용한 TRACE 방법은 Application Load Balancer에서 지원하지 않습니다.
  • HTTP 408: Request timeout
    • 클라이언트가 유휴 제한 시간 만료 전에 데이터를 전송하지 않았습니다. TCP 연결 유지를 전송해도 이 시간 제한을 막지 못합니다. 각 유휴 제한 시간이 지나기 전에 최소 1바이트의 데이터를 전송하십시오. 필요한 만 큼 유휴 제한 시간의 길이를 늘립니다.
  • HTTP 413: Payload too large
    • 대상이 Lambda 함수이고 요청 본문이 1MB를 초과합니다.
  • HTTP 414: URI too long
    • 요청 URL 또는 쿼리 문자열 파라미터가 너무 큽니다.
  • HTTP 460
    • 로드 밸런서가 클라이언트에서 요청을 수신했지만, 유휴 제한 시간이 종료되기 전에 클라이언트가 로드 밸런 서와의 연결을 종료했습니다.
    • 클라이언트 제한 시간이 로드 밸런서의 유휴 제한 시간보다 큰지 확인합니다. 클라이언트 제한 시간이 끝나 기 전에 대상이 클라이언트에 응답을 제공하는지 확인하거나, 클라이언트가 제한 시간을 지원할 경우 로드 밸런서의 유휴 제한 시간에 맞게 클라이언트 제한 시간을 늘립니다.
  • HTTP 463
    • 로드 밸런서가 IP 주소가 30개가 넘는 X-Forwarded-For 요청 헤더를 받았습니다
  • HTTP 500: Internal server error
    • You configured an AWS WAF web access control list (web ACL) and there was an error executing the web ACL rules.
    • You configured a listener rule to authenticate users, but one of the following is true:
      • The load balancer is unable to communicate with the IdP token endpoint or the IdP user info endpoint. Verify that the security groups for your load balancer and the network ACLs for your VPC allow outbound access to these endpoints. Verify that your VPC has internet access. If you have an internalfacing load balancer, use a NAT gateway to enable internet access.
      • The size of the claims returned by the IdP exceeded the maximum size supported by the load balancer.
      • A client submitted an HTTP/1.0 request without a host header, and the load balancer was unable to generate a redirect URL.
      • A client submitted a request without an HTTP protocol, and the load balancer was unable to generate a redirect URL.
      • The requested scope doesn't return an ID token.
  • HTTP 501: Not implemented
    • 로드 밸런서가 미지원 값이 포함된 Transfer-Encoding 헤더를 받았습니다. 지원되는 값 전송-인코딩 are chunked and identity. 대안으로서, 콘텐츠 인코딩 헤더.
  • HTTP 502: Bad gateway
    • The load balancer received a TCP RST from the target when attempting to establish a connection.
    • The load balancer received an unexpected response from the target, such as "ICMP Destination unreachable (Host unreachable)", when attempting to establish a connection. Check whether traffic is allowed from the load balancer subnets to the targets on the target port.
    • The target closed the connection with a TCP RST or a TCP FIN while the load balancer had an outstanding request to the target. Check whether the keep-alive duration of the target is shorter than the idle timeout value of the load balancer.
    • The target response is malformed or contains HTTP headers that are not valid.
    • The load balancer encountered an SSL handshake error or SSL handshake timeout (10 seconds) when connecting to a target.
    • The deregistration delay period elapsed for a request being handled by a target that was deregistered. Increase the delay period so that lengthy operations can complete.
    • The target is a Lambda function and the response body exceeds 1 MB.
    • The target is a Lambda function that did not respond before its configured timeout was reached.
  • HTTP 503: Service unavailable
    • 로드 밸런서의 대상 그룹에 등록된 대상이 없습니다.
  • HTTP 504: Gateway timeout
    • The load balancer failed to establish a connection to the target before the connection timeout expired (10 seconds).
    • The load balancer established a connection to the target but the target did not respond before the idle timeout period elapsed.
    • The network ACL for the subnet did not allow traffic from the targets to the load balancer nodes on the ephemeral ports (1024-65535).
    • The target returns a content-length header that is larger than the entity body. The load balancer timed out waiting for the missing bytes.
    • The target is a Lambda function and the Lambda service did not respond before the connection timeout expired.
  • HTTP 561: Unauthorized
    • 사용자를 인증하도록 리스너 규칙을 구성했지만, 사용자를 인증할 때 IdP가 오류 코드를 반환했습니다.

Cross-Zone Load Balancing

교차 영역 로드 밸런싱을 사용하면 Classic Load Balancer에 대한 각각의 로드 밸런서 노드가 활성화된 모든 가용 영역에 있는 등록된 인스턴스간에 요청을 균등하게 분산한다.

Cross-Zone LB가 꺼져있다면
Cross-Zone LB가 켜져있다면

 

더 자세한 로드발란싱 알고리즘에 대해 알고 싶다면 하단 페이지를 참고하자

https://velody.tistory.com/70

 

'Cloud > AWS' 카테고리의 다른 글

AWS 인터뷰 정리  (0) 2020.09.06
Simple Email Service - SES  (0) 2020.09.05
S3 Glacier  (0) 2020.09.04
CloudFront  (0) 2020.09.03
S3 - Simple Storage Service  (0) 2020.09.02