Original text reproduced from: http://tomyz0223.iteye.com/blog/1046992
nginx’s upstream currently supports 5 methods of allocation
1. Polling (default)
Each request is in chronological order Allocate to different backend servers one by one. If the backend server goes down, it can be automatically eliminated.
upstream backserver { server 192.168.0.14; server 192.168.0.15; }
upstream backserver { server 192.168.0.14 weight=10; server 192.168.0.15 weight=10; }
upstream backserver { ip_hash; server 192.168.0.14:88; server 192.168.0.15:80; }
upstream backserver { server server1; server server2; fair; }
upstream backserver { server squid1:3128; server squid2:3128; hash $request_uri; hash_method crc32; }
proxy_pass http://backserver/ ; upstream backserver{ ip_hash; server 127.0.0.1:9090 down; (down 表示单前的server暂时不参与负载) server 127.0.0.1:8080 weight=2; (weight 默认为1.weight越大,负载的权重就越大) server 127.0.0.1:6060; server 127.0.0.1:7070 backup; (其它所有的非backup机器down或者忙的时候,请求backup机器) }
The above introduces the NGinx load balancing strategy, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.