A load balancer is a type of HTTP server responsible for distributing traffic (routing) to various web servers based on the rules defined by the developer. A load balancer, in general, is a very fast and specialized application. Trying to implement similar logic in a web server might not be optimal because the resources available to your web server have to be split between handling requests for your business logic and requests that need to be routed. Also, a load balancer provides us with a lot of features out of the box such as these:
- Load balancing algorithms: The following are some algorithms for load balancing:
- Random: Distribute randomly across the servers.
- Round robin: Distribute equally and sequentially across servers. ...