Print
카테고리: [ Amazon Web Services ]
조회수: 6802

1. 개요

지난 2017년 9월 7일 새로운 Load Balancer인 Network Load Balancer가 발표되었다.

https://aws.amazon.com/ko/blogs/aws/new-network-load-balancer-effortless-scaling-to-millions-of-requests-per-second/


2. 비교자료

You can select the appropriate load balancer based on your application needs. If you need flexible application management, then we recommend you to use Application Load Balancer. If extreme performance and static IP is needed for your application, then we recommend you to use Network Load Balancer. If you have an existing application that was built within the EC2-Classic network, then you should use Classic Load Balancer.

Feature

Application Load Balancer

Network Load Balancer

Classic Load Balancer

Protocols

HTTP, HTTPS

TCP

TCP, SSL, HTTP, HTTPS

Platforms

VPC

VPC

EC2-Classic, VPC

Health checks

CloudWatch metrics

Logging

Zonal fail-over

Connection draining (deregistration delay)

Load Balancing to multiple ports on the same instance

 

WebSockets

 
IP addresses as targets    

Load balancer deletion protection

 

Path-Based Routing

   

Host-Based Routing

   

Native HTTP/2

   
Configurable idle connection timeout  

Cross-zone load balancing

 

SSL offloading

 

Sticky sessions

 

Back-end server encryption

 

Static IP

 

 

Elastic IP address

 

 

Preserve Source IP address

 

 

3. 특징

3-1. 해시 라우팅 

NLB는 해시 라우팅 알고리즘을 제공한다. (출처: https://docs.aws.amazon.com/ko_kr/elasticloadbalancing/latest/userguide/how-elastic-load-balancing-works.html)

Network Load Balancer에서는 연결을 수신하는 로드 밸런서 노드가 프로토콜, 원본 IP 주소, 원본 포트, 대상 IP 주소 및 대상 포트에 따라 흐름 해시 알고리즘을 사용하여 대상 그룹에서 기본 규칙을 위한 대상을 선택합니다. 그러면 동일한 원본에서 동일한 대상으로 이동하는 트래픽에 세션 고정이 제공됩니다.

3-2. 고정 IP

3-3. Pre-warm


4. 구성

4-1. 대상 그룹 (Target Group) 생성

이름, VPC, 프로토콜 정도만 정의하면 바로 생성 가능하다.
프로토콜은 반드시 TCP를 선택한다. HTTP 방식의 대상 그룹을 만들면 NLB에 할당이 불가능하다.

4-1.1. 대상 그룹에 인스턴스 추가

대상 그룹에 넣을 인스턴스를 선택한다. 단, 현재 기동되어 있는 인스턴스만 보인다. (중지중인 인스턴스는 안됨)

4-1-2. 대상 그룹 삭제

만약 대상 그룹이 로드밸런서에 할당되어 있다면 삭제가 불가능하다.

Target group 'arn:aws:elasticloadbalancing:ap-northeast-2:.....:targetgroup/xxxxx/yyyyy' is currently in use by a listener or a rule

4-2. NLB 생성


5. nslookup

5-1. backend에 하나의 AZ에 해당하는 인스턴스만 존재할 때

Non-authoritative answer:
Name:   nlb-an2-sarc-......elb.ap-northeast-2.amazonaws.com
Address: 10.0.0.83

하나의 IP만 lookup된다.

5-2. backend에 두개의 AZ에 해당하는 인스턴스가 모두 존재할 때

Non-authoritative answer:
Name:   nlb-an2-sarc-......elb.ap-northeast-2.amazonaws.com
Address: 10.0.1.169
Name:   nlb-an2-sarc-......elb.ap-northeast-2.amazonaws.com
Address: 10.0.0.83

2개의 IP가 lookup된다.

5-3. 중지 감지

각 AZ에 하나씩 Tomcat이 기동되어 있는 상황일 때, 특정 AZ에 속한 EC2 내 Tomcat을 shutdown하면 궁극적으로 NLB에서 해당 AZ에 해당하는 IP가 빠지는 것을 확인할 수 있다.

순번 Tomcat 중지 시간 NLB IP 제거 시간 소요 시간 Heal Check 설정
1 04:42:00 04:43:12 72초 3/3/10/30
2 04:41:00 04:52:01 61초 3/3/10/30
3 05:04:59 05:05:52 53초 3/3/10/30
4 05:14:00 05:14:33 33초 3/3/10/30
5 05:17:05 05:18:34 89초 3/3/10/30
6 07:02:31 07:03:17 46초 2/2/10/30
7 07:08:11 07:09:16 65초 2/2/10/30
8 07:12:08 07:13:16 68초 2/2/10/30
9 07:15:25 07:16:20 55초 2/2/10/30
10 07:17:48 07:18:20 32초 2/2/10/30

5-4. 기동 감지

5-3과 반대되는 상황이다.

순번 Tomcat 기동 시간 NLB IP 인식 시간 소요 시간 Heal Check 설정
1 04:47:18 04:48:10 52초 3/3/10/30
2 04:43:06 04:54:01 56초 3/3/10/30
3 05:11:35 05:12:32 57초 3/3/10/30
4 05:15:11 05:16:34 83초 3/3/10/30
5 05:19:01 05:19:34 33초 3/3/10/30
6 07:06:21 07:07:16 55초 2/2/10/30
7 07:10:15 07:11:16 61초 2/2/10/30
8 07:13:50 07:14:16 26초 2/2/10/30
9 07:16:43 07:17:20 37초 2/2/10/30
10 07:18:46 07:19:20 34초 2/2/10/30

6. WEB-WAS 사이에 NLB 구성시 구성 방법


7. CLI

aws elb describe-load-balancers 사용 시 NLB 정보는 확인할 수 없다. --load-balancer-names 옵션을 써도 그렇다.

An error occurred (LoadBalancerNotFound) when calling the DescribeLoadBalancers operation: There is no ACTIVE Load Balancer named 'my-test-nlb'

elbv2 를 써야 한다.

aws elbv2 describe-load-balancers --names