In the last session we covered some of the most common load balancing techniques and also the basics about load balancing. Let us now take a look at the different types of load balancers.
Different types of load balancers
Unlike the earlier classification, this one is based on where the load balancing is done. Load balancing can be performed at the network layer and the application layer of the OSI model.

Layer 4
Load balancing done in the Transport Layer based on protocols like TCP and UDP, using information based on IP addresses, port numbers, and the likes - but never relying on application data or the content of the data that’s being sent. They can either establish and terminate connections, or simply forward packets without doing anything to them.
They are generally fast and lightweight - as it doesn’t really bother with the content of the packet apart from the headers. These are used for high speed routing, backend scaling, non-http or https traffic. Many of the hardware load balancers out there do Layer 4 routing - F5 BIG-IP, Citrix ADC etc.
Layer 7
They are based on application layer protocols. Load balancing decisions in this layer is based on HTTP headers, URLs, cookies similar data like for example, email address, user id, phone number, whatever. You might have seen API gateways do rate limiting and HTTP routing and request header rewrites etc. They are all Layer 7 load balancers.
Info
Transport Layer Security (TLS), formerly known as Secure Sockets Layer (SSL), is the standard security tech for creating an encrypted link between a web server and a browser. This connection ensures that everything that is transferred between the browser to the web server and back are encrypted. However, generally after the connection is made to an Application Gateway, which is the entry point of the request to a pool of API/web servers, the encryption is terminated, as the connection beyond that point is within a secure network. This is called TLS termination and is generally done in Layer 7 but there are some Layer 4 load balancers that support this too.
Load balancers IRL
So far we have looked at a lot of theory on what the different types of load balancers are and what they do etc. Let us now take a look at how they are really configured in a data centre like the ones that provide you AWS or the likes.
Load balancing in a data centre is often done in multiple layers. All these coordinate together to make the right forwarding decisions. They are often layered as tiers 0 to tier 3. The lowest tier often balances the load to the highest tier. And the highest tier load balancers are the ones that actually balances the load to the back-end servers. All these load balancers working together helps reduce the load on the back-end servers.
Different implementations of load balancers
If you have read the previous article and have arrived thus far, you are probably already thinking that there are so many ways to implement load balancers, they can be coded as applications/processes running somewhere in a server, or could be embedded into hardware. Based on the needs of the application, you might even go for specific types.
Hardware
The origin of load balancers happened sometime in the 1990s. They came as special devices, like a printer or a video cassette player and very pretty expensive as they were niche. Most hardware load balancers are extremely resource efficient and can handle a very large number of concurrent users. But as they are pretty expensive not every company can afford them and configuring redundancy can be really expensive as you would need to buy at least two of them and incur double the cost and by default are locked to the hardware vendor.
Software
These are the flexible cousins of the hardware counterparts. They are cheaper and more accessible and can be updated regularly through patches and can be deployed at scale.
An extension of this today is the rise in Load Balancing as a Service. Cloud providers give their customers the ability to use load balancers to balance load globally between different availability zones. They cost you based on usage and often comes with lots of monitoring in built.
Summary
That covers the basics of load balancing for a system design interview.