What are the types of Elastic Load Balancer and when do you use each?
Application Load Balancer works at layer 7 for HTTP and HTTPS with path and host routing. Network Load Balancer works at layer 4 for TCP, UDP and TLS with very high performance and static IPs. Gateway Load Balancer fronts network appliances. Classic is legacy.
Explain it simply
An ALB is a receptionist who reads the visitor's request letter and sends it to the right department: billing, support or sales. An NLB is a fast gate guard who only checks the vehicle number and waves it through, with no time to read the letter.
Example
ALB (Layer 7: HTTP, HTTPS, gRPC, WebSocket)
routing by path /api, host shop.example.com, headers, query strings
targets: instances, IPs, Lambda, containers
use: web apps, microservices
NLB (Layer 4: TCP, UDP, TLS)
millions of requests per second, very low latency
static IP or Elastic IP per AZ
use: gaming, IoT, non-HTTP protocols, fixed IPs for allow-listing
GWLB (Layer 3)
sends traffic through firewalls and inspection appliances
use: third-party security virtual appliances
CLB Classic: previous generation, avoid for new workIf the question is "route /api to one service and /web to another", the answer is ALB. If it is "my client needs a fixed IP address" or "non-HTTP traffic", the answer is NLB.
What to say in the interview
"ALB for HTTP and HTTPS with content-based routing, NLB for high-performance TCP or UDP and static IPs, Gateway Load Balancer for inline security appliances, and Classic only for legacy. For microservices on a web app I choose ALB."
Common mistakes
- Choosing NLB when path-based routing is needed.