I use nginx to load balance my tornado app. There are 3 instances of the same application(listen on different port) on server_A. Below are my configuration.
http {
upstream myapp1 {
server server_A_IP:8888;
server server_A_IP:8887;
server server_A_IP:8886;
}
server {
listen 80;
location / {
proxy_pass http://myapp1;
}
}
}
Now I have another server_B, and also I start 3 instances on this server, so I add 3 lines to my config's upstream.
upstream myapp1 {
server server_A_IP:8888;
server server_A_IP:8887;
server server_A_IP:8886;
server server_B_IP:8888;
server server_B_IP:8887;
server server_B_IP:8886;
}
This would be ugly if I start 10 instances on each server or add a large amount server to upstream.
Is there any proper way to to this? What is the recommand way to load balance multi server? Thanks!