nginx五种负载均衡算法实现方式
1、轮询upstream test { server 192.168.1.160:80; server 192.168.1.167:80; }
2、for i in $(seq 100); do curl http://192.168.1.43;done>1.txtroot@fabu-10-221:~# cat 1.txt |grep "192.168.1.160"|wc -l50root@fabu-10-221:~# cat 1.txt |grep "192.168.1.167"|wc -l50
3、weightupstream test { server 192.168.1.160:80 weight=1; server 192.168.1.167:80 weight=5; }
4、100刚好是20的5倍
5、ip_hashupstream test { ip_hash; server 192.168.1.160:80; server 192.168.1.167:80; }
6、root@fabu-10-221:~# cat 1.txt |grep "192.168.1.167"|wc -l120root@fabu-10-221:~# cat 1.txt |grep "192.168.1.160"|wc -l0root@fabu-10-221:~# for i in $(seq 120); do curl http://192.168.1.43;done >1.txt结果锁定在同一台机器上
7、fairupstream test { server 192.168.1.160:80; server 192.168.1.167:80; fair;