Load balancer is a reverse proxy that helps you to distribute the load and forward requests to different servers. The are useful for a few reasons:
- Helps to redirect requests to healthy servers
- Prevents overloading
- Eliminates a single point of failiure
Load balancers can be implemented with Hardware or Software. Software is a cheaper option, so default to this unless you have specific requirements to use hardware.
Additionally, load balancers include:
- SSL termination, with helps to decript incroming and encript outgoing requests and resposnes. This eliminates the need to do that on a particular
- Session persistance which helps to route a client to the same resource. You can use Cookies for that.
Load Balancing Algorithms
- Round Robin
- Weighted Round Robin
- Weighted Least Connection
- Random
- Latency Based Routing
- Geolocation Routing
Disadvantages
- Load balancer can become a bottleneck if not configured properly and does not distribute load evenly.
- When you have one load balancer, it becomes a single point of failure. You need to add multiple load balancers which introduces complexity