Load balancer¶
A load balancer evenly distributes incoming traffic among web servers
- distributes incoming web traffic across multiple backend servers
- allow applications
- ✅ scale up and down with demand
- achieve HA
- ✅ performance. By distributing the workload evenly across servers, load balancers can improve the average response time.
- ✅ Reliability. Load balancers provide redundancy and can minimize downtime by automatically detecting and replacing unhealthy servers.
- ✅ For better security, private IPs are used for communication between servers.
- ⛔ single point of failure. You need to use multiple load balancers. DNS round robin can be used to balance traffic across different load balancers.
- ⛔ user sessions. The user's requests can be handled by different servers.
Distributing traffic strategies¶
- Round robin
- Least connections
- Consistent hashing. like database sharding, based on IP address or URL
Requirements to Load balancer:¶
- efficiency
- HA
Implementation of LB¶
- HAProxy
- Nginx
Tips¶
- 💡 In a microservice architecture, it's common to use load balancers in front of each internal service so that every part of the system can be scaled independently.