DEV Community

Anthony Dreessen
Anthony Dreessen

Posted on

Explain Load Balancers Like I'm Five

Why are they special? Wot's the big deal.

Top comments (5)

Collapse
 
aswathm78 profile image
Aswath KNM

Load balancers are available in two types but it's job is same .

That is handling network traffic

Have you ever been to a store where the crowd is so high ,such that one employee can't handle them all ??

That's when the store manager sends another one to take care of the crowd . If needed he will add more employees to handle the crowd .

So that each customer will get things done in minimal time .

If the crowd is small, he will remove them from crowd control.

Load balancer's job is similar to the manager's job.

When too many requests from users arrives server it'll take care of requests and split them to other servers . So no machine will be used too much.

Why load balancer exists is , a server machine can accept a limited number of requests . To make them work efficiently and rearrange requests to other machines load balancer exists

Collapse
 
rafaelsorto profile image
Rafael Sorto

You go to a restaurant, the server (Loadbalancer) takes the order from your parents, he then goes to the kitchen and sees that one cook(application server) is busy creating a delicious meal for another a party of 5, the other cook(another application server) is just there drinking water. The server places your order in the queue for the free cook(least loaded app server). He cooks your delicious meal and hands it back to the server (loadbalancer) so he can return to your table with that delicious mac and cheese because remember after all you are just 5.

Collapse
 
rhymes profile image
rhymes

You are five, you need constant attention when you're home from preschool.

You have two parents, one is busy dealing with your younger sibling, the other is giving you their full attention.

The busy parent will listen to you in a few moments, just right after your younger sibling has been put to bed.

Being this a short story I'm going to insert the following plot device: both parents cannot give their attention to you at the same time.

Have fun :D

Collapse
 
slavius profile image
Slavius • Edited

It's all about scaling. There are 2 types of scaling:

  • Vertical - you keep adding resources to your single system until you run out of space - e.g. until you have no more free memory slots to expand your RAM or ports free to connect another hard drive
  • Horizontal - you keep adding more small autonomous systems, each having it's own portion of resources that in sum give you the power you need. You can do this as long as you have physical space which is very efficient.

Load Balancers come in play when you scale horizontally. The individual systems are called nodes in load balancer terminology.

Generally you put load balancer in front of these nodes to handle all the work first. Then the load balancer decides how to spread the load across all nodes.

Features of the load balancer can be summed up as:

  • balancing the load across available nodes
  • keeping information about health of nodes (doing regular health checks) to prevent routing requests to dead nodes - this allows an awesome way to do maintenance because you can mark nodes as inactive while doing the maintenance and/or reboots and the application still works by serving requests from other active nodes
  • keeping information about the load on each node (CPU load, RAM usage, number of active connections, number of connections/second to each node) to prevent overloading already heavily used nodes
  • keeps track of sessions (based on source IP address+port or HTTP cookie) to route the same client always to the same node (necessary if the remaining nodes are not session aware - imagine you log in to an application and then your next request would be redirected to a different node that has no idea you were already authenticated - you would end up on login screen again ending in a loop)
  • offloading - load balancer can take over responsibility of compressing resources and sending them to end clients leaving more CPU power for application servers. The same way it can terminate and negotiate HTTPS sessions, which is also expensive because of SSL/TLS cryptography happening for each client. Similarly load balancer can also cache frequently used resources in memory or on a fast storage to prevent retrieving them from nodes all the time.

TL;DR
Load balancers [can] make your service more reliable, easily scalable, more performant and resilient to outages.

Collapse
 
joshualjohnson profile image
Joshua Johnson

The load balance tells you what sandbox to play in.