Episode 125 - Layer 4 vs Layer 7 Load Balancing

The Backend Engineering Show with Hussein Nasser

Episode | Podcast

Date: Wed, 29 Jan 2020 23:17:56 GMT

<p>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.</p> <p><br /></p> <p>Layer 4 - haproxy, NLB&nbsp;</p> <p>Pros</p> <p>&nbsp;- great for simple packet-level load balancing&nbsp;</p> <p>- Fast and efficient doesn’t look at the data&nbsp;</p> <p>- More secure as it cant really look at your packets. So if it was compromised no one can look</p> <p>&nbsp;- Uses NAT &nbsp;- One connection between client and server NATed&nbsp;</p> <p><br /></p> <p>Cons</p> <p>&nbsp;- Can't do smart load balancing based on the content, such as switch request based on the requested media type</p> <p>&nbsp;- Cant do microservices with this type</p> <p>&nbsp;- Has to be sticky as it is a stateful protocol (all segments)</p> <p><br /></p> <p>Layer 7 (Nginx , haproxy)</p> <p>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..</p>