Load balancers allow you to route client requests across multiple servers in order to maximize speed and capacity utilization and ensure that no one server is overworked. NGINX is one such load balancer that also acts as a web server and reverse proxy.
If you want to load balance between three servers using NGINX, you might have something like this in your nginx.conf
configuration file.
http {
upstream myapp {
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
}
server {
listen 80;
location / {
proxy_pass http://myapp;
}
}
}
Here, you hardcode the three servers you want to load balance between in the configuration file. If you want to load balance between more servers, you have to add a line for each additional server you want to add, meaning you have to hardcode all the servers into your configuration file.
Is there a way to dynamically and easily scale up the number of servers you want to load balance between? How does load balancing scale as the load on your servers increase?