![The Backend Engineering Show with Hussein Nasser artwork](https://is1-ssl.mzstatic.com/image/thumb/Podcasts113/v4/cd/d5/bb/cdd5bbe4-0e12-9615-1bd5-6f578f2e6875/mza_5436295260688338257.jpg/100x100bb.jpg)
Episode 125 - Layer 4 vs Layer 7 Load Balancing
The Backend Engineering Show with Hussein Nasser
English - January 29, 2020 23:17 - 37 minutes - 21.5 MB - ★★★★★ - 5 ratingsTechnology Homepage Download Apple Podcasts Google Podcasts Overcast Castro Pocket Casts RSS feed
Load balancing is process of balancing incoming requests to multiple machines, processes or services. In this video we will explain two types of load balancers, layer 4 and layer 7.
Layer 4 - haproxy, NLB
Pros
- great for simple packet-level load balancing
- Fast and efficient doesn’t look at the data
- More secure as it cant really look at your packets. So if it was compromised no one can look
- Uses NAT - One connection between client and server NATed
Cons
- Can't do smart load balancing based on the content, such as switch request based on the requested media type
- Cant do microservices with this type
- Has to be sticky as it is a stateful protocol (all segments)
Layer 7 (Nginx , haproxy)
This type of proxy actually looks at the content and have more context, it knows you are visiting the /users resources so it may forward it to a different server. Essential and Great for microservices , it knows the content is video:image etc..