ALB, NLB 비교
**AWS 기준으로 설명
ALB, Application Load Balancer
OSI 7 계층(Application Layer, L7) 에서 작동하며 HTTP/S 프로토콜 지원
경로 기반 라우팅, 호스트 기반 라우팅과 같은 개선된 라우팅 기능 지원
Path-based routing :
유입 트래픽을 로드밸런싱할 때 URL Path를 기반으로 하는 것
예를 들어 "/api" 와 같은 URL Path에 대한 모든 Request를 어떤 target group으로 라우팅함
Web service(정적), API service(동적) 2가지가 있다고 했을 때
HTML과 같은 static 파일들은 Web service에 요청을 전달하고
JSON data와 같은 것들은 API service에 요청을 전달함
즉, prefix(path)에 따라 target group으로 로드밸런싱 되는 것임
Host-based routing :
유입 트래픽을 로드밸런싱할 때 Hostname을 기반으로 하는 것
예를 들어 blog와 E-commerce 서비스 2가지가 있다고 했을
blog.example.com, store.example.com와 같이 2가지 Hostname을 구분하여
각자의 서비스에 각각 트래픽을 전달함
즉, Hostname에 따라 각 target group으로 로드밸런싱 되는 것임
SSL/TLS 제어
SSL/TLS는 암호화하기 위한 보안 프로토콜임
server certification을 관리
일반적으로 Secure Connection을 위한 Handshake를 Establishment cost는 높은 편임
Encrypted된 유입 트래픽에 대한 복호화를 ALB에서 할 수 있음
즉, ALB에서 포워딩 된 트래픽은 복호화된 트래픽임
ALB에서 SSL/TLS를 관리함으로써 여러 target group 관리에 대한 공수를 줄여줌
그럼으로써 target instance는 Scale-in, out 으로부터 자유로워짐
NLB, Network Load Balancer
OSI 4 계층(Transport Layer, L4) 에서 작동하며 TCP, UDP프로토콜 지원
IP 기반 라우팅 지원
트래픽의 Destination IP를 기반으로 라우팅하는 것임
라우팅 테이블, 라우팅 룰에 따라 로드밸런싱됨
SSL/TLS 제어
**ALB와는 조금 다름 ALB는 Built-in 되어있지만 NLB에선 따로 설정해야함
ALB보다 빠른 속도
ALB보다 낮은 Latency를 가지고 있음
비교표
ALB | NLB | |
Protocols | HTTP/1, HTTP/2, gRPC | TCP, UDP |
Performance | Low Latency | Very Low Latency |
Traffic Spikes | ⚠️ Inform AWS Support about huge traffic spikes | ✅ Deals with huge and unexpected traffic spikes |
Static IP Addresses | ❌ No. However, you could place an NLB in front of an ALB. | ✅ Yes |
TLS Termination | ✅ Yes | ✅ Yes |
Targets | EC2 Instance, IP Address, Lambda | EC2 Instance, IP Address, ALB |
Client IP preservation | Use HTTP header X-Forwarded-For | Optional, but comes with limitations |
Routing Algorithm | Round Robin or Least Outstanding Requests | Random |
Deregistering targets | ALB stops sending requests and waits for open requests | NLB stops opening new connections, but the application needs to terminate connections properly |
Multiplexing | ✅ Yes, reuses connections to targets | ❌ No, does not reuse connections to targets |
Maximum number of targets | 1000-5000 | 500-1000 |
Security Group | Security group of ALB controls inbound traffic, targets reachable from ALB only | Security group of targets control inbound traffic, targets reachable from clients |
Request based routing | ✅ Yes, based on hostname, path, header, … | ❌ No |
WAF | ✅ Yes | ❌ No |
Authentication | ✅ Yes (OpenID Connect, SAML, …) | ❌ No |
Slow Start Mode | ✅ Yes | ❌ No |
Sticky Session | ✅ Yes | ❌ No |
IPv6 | ✅ Yes | ✅ Yes |
Costs | 💰💰💰 | 💰💰 (But causes more connections and therefore higher load on targets.) |
** AWS ELB에는 ALB, NLB 타입 2가지가 존재
참고링크
https://blog.cloudcraft.co/alb-vs-nlb-which-aws-load-balancer-fits-your-needs/