What should you know about the Load Balancer?
Today you can’t imagine any software without a lot of interactions. Whether it’s external calls, like browser’s requests to servers. Or internal communications between components in the system. That’s why routing traffic is becoming a very essential part of it. And thus you can’t create any new modern software system without using a load balancer. With load balancing, we use other definitions like: L4, L7, hardware, and software. Software developers should understand these words.
In this article, I’ll give you explanations for those terms. After reading this article you could understand them.
Reasons to use a balancer
The main reason to use balancer is to efficiently distribute traffic among servers. It provides the next features:
- scalability. You can add new servers and evenly spread loading between them
- flexibility. It’s possible to make maintenance on particular servers that are temporarily excluded from routing.
- availability. In case if the server is down balancer could exclude this server from routing
Of course, you shouldn’t expect from balancer to solve all these problems. There are a lot of configurations to adjust it. And in case of incorrect adjustments balancer could provide big problems.
The other thing worth mentioning is a reverse proxy. It is one special case of a load balancer. Proxying is a hiding client from the outside internet. A reverse proxy is hiding the internet from the outside client.
There are several ways for balancer to where to route the traffic, few of them are:
- round robin. Next request routed to the next server, when it’s last one then next start with the first one.
- least time. Routing requests to the server that has the fastest response.
- randomly. The next request is routed to the random server.
- by information in the request. It could be any informations like cookies or request’s parameters.
Hardware and software
There are two main classes: hardware and software. Hardware balancers work as out of the box devices. They are the first balancers. Software balancer could be used on commodity hardware and even on virtual servers.
We could also highlight cloud balancing. Special type provided by cloud platforms.
L4 and L7
The other two groups of balancers are: L4 and L7. This division is associated with levels in the OSI model. L4 balancer uses transport layer and L7 uses application level. It’s not a strict division, because could be a mix of them, but it provides a conceptual difference between them.
L4 balancer works on the network layer. There are two main protocols here TCP and UDP. And this balancer ensures you that within the same session traffic will be routed to the same server. Let me explain it from browser point of view. For each new request, a browser opens a new session, at least for old HTTP versions, on the transport layer and each new request with the help of balancer could be routed to different servers.
Opening a new session is a very time-consuming operation and therefore revealed new types of communications where a client could use the same session for different requests. And if in the L4 balancer all the requests from the same client could be routed to only one server, at the application level you could do more sophisticated balancing based on any criteria in the request.
In this article, we covered a basic understanding of the load balancer. We could easily operate with terms: L4, L7, hardware, and software balancer. And learn in which situations they could be used. Try to find any balancer in your system and what that type and why is it so. I will be happy to hear about it in comments! Drink coffee and balance your system!
If you liked this article please clap. 👇