# ELB Types

There are 3 kind of load balancer on AWS

1. Application Load Balancer (ALB)
2. Network Load Balancer (NLB)
3. Gateway Load Balancer (GWLB)

Some load balancers can be setup as i**nternal (private) or external (public) ELB.**

<img src="https://2166680554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FP9VzT74ziIucCaJgfreE%2Fuploads%2Fh6hIH3z9Co2esOxcxS60%2Ffile.excalidraw.svg?alt=media&#x26;token=a6f93e3b-bfac-41a3-89a3-704755188492" alt="" class="gitbook-drawing">

### (1) Application Load Balancer (ALB)

Application load balancers is Layer 7 (Http). It support for Http/2 and websocket apart from this it is able to redirect HTTP to HTTPS. It routes traffic to different target group. Target group can be inside the same machine (multiple containers) or across machine (multiple applications).&#x20;

There are a lot of way routing traffic including.

1. Routing based on path in URL\
   \- example.com/users\
   \- example.com/posts
2. Routing based on hostname \
   \- one.example.com\
   \- two.example.com
3. Routing based on Query String , Headers\
   \- example.com/users?id=123\&order=false\
   \- example.com/users?id=123\&order=true

#### Usecase

* Microservice&#x20;
* Container based application

#### \*\*Good to know

* Application server (target group) don't see the ip of the client directly. Load balancer will attach the header `X-Forwarded-For` , `X-Forwarded-Port` and `X-Forwared-Proto` in the request so you can get `IP` , `Port` and `Protocol` from its.

<br>

<img src="https://2166680554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FP9VzT74ziIucCaJgfreE%2Fuploads%2FCUVVZoHUxaMefnom8SXf%2Ffile.excalidraw.svg?alt=media&#x26;token=082eeb1f-b7a8-4e38-bdb4-da0df0ebea12" alt="" class="gitbook-drawing">

### (2) Network Load Balancer (NLB)

Network load balancers is Layer 4 (TCP/UDP). It allow to forward TCP & UDP traffic to instances. It handles milion request per seconds (High performance). NLB has one static IP per AZ and support assign Elastic IP. It supports for HTTP , HTTPS and TCP/UDP.<br>

&#x20;

<img src="https://2166680554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FP9VzT74ziIucCaJgfreE%2Fuploads%2FglmhDmkvgmEXm3ReKzs0%2Ffile.excalidraw.svg?alt=media&#x26;token=88904a7b-7c5b-429d-b34c-5778f02959a8" alt="" class="gitbook-drawing">

#### Usecase&#x20;

* High performance load
* Control TCP/UDP

### (3) Gateway Load Balancer (GWLB)

Gateway Load Balancer is Layer 3 (Network Layer). It is a single entry/exit  for all traffic. This load balancer will forward request to virtual appliance for fraud detection or something . It used `GENEVE` protocol on port 6081.

<br>

<img src="https://2166680554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FP9VzT74ziIucCaJgfreE%2Fuploads%2FONYDG51q73h7PbG6cQc6%2Ffile.excalidraw.svg?alt=media&#x26;token=101037b9-dd05-4151-b045-5e2dac2edcbb" alt="" class="gitbook-drawing">

#### Usecase

* Firewall&#x20;
* Prevention System
* Payload Mainpulation
