3

I'm new to AWS. I started learning about ALB and NLB. I know ALB working in Layer 7 protocols and NLB working in layer 4 protocols.

Can anyone please explain the real time example of ALB and NLB?? When to use ALB and NLB??

Even though all the web application will use TCP protocols for making connection between server and client.

So Is ALB use the TCP (layer 4) protocols??
Then what is the different between them? Can anyone please explain briefly???

prem sekar
  • 71
  • 2
  • 5

2 Answers2

6

In summary: an NLB only knows about TCP, while an ALB knows everything about the request.

An NLB can only route a request based on IP addresses and other TCP-package info.

An ALB can route a request by looking at the content of it: what protocol is it using (HTTP, HTTPS)? What path is it trying to query (/api/v1, /api/v2)? What content-type is it requesting?

So, if you want requests for the v1 API endpoint to be routed to an autoscaling group of EC2 instances and requests for the v2 API endpoint routed to another group of instances, then your best option is the ALB because it allows you to configure rules that make your desired routing possible.

On the other hand, if you just want that clients coming from Germany are routed to one autoscaling group and clients from the USA to another group, the NLB should be sufficient because you can set up rules that match the IP addresses of those countries.

Piero Hernandez
  • 435
  • 4
  • 10
4

TL;DR To load balance HTTP requests, use an ALB. For TCP/UDP load balancing, use an NLB.

An ALB (Application Load Balancer) understands HTTP. If you need to do HTTP-based routing (e.g., routing to different targets depending on the request path) you need to use an ALB.

Unique features of ALBs include:

  • HTTP path-based routing
  • HTTP header-based routing
  • Redirects
  • Lambda functions as targets

An NLB (Network Load Balancer) operates at the transport level (TCP/UDP). NLBs are more performant than ALBs because they don't need to parse HTTP messages.

NLBs support some unique features too:

  • Static IP
  • Elastic IP addresses
  • Preserving the source IP

You can see a full comparison of features on the Elastic load balancing features page.

Edward
  • 5,148
  • 2
  • 29
  • 42