nginx五种负载均衡算法实现方式

 时间:2025-01-20 23:30:08

1、轮询upstream test { server 192.168.1.160:80; server 192.168.1.167:80; }

nginx五种负载均衡算法实现方式

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

nginx五种负载均衡算法实现方式nginx五种负载均衡算法实现方式

3、weightupstream test { server 192.168.1.160:80 weight=1; server 192.168.1.167:80 weight=5; }

nginx五种负载均衡算法实现方式

4、100刚好是20的5倍

nginx五种负载均衡算法实现方式

5、ip_hashupstream test { ip_hash; server 192.168.1.160:80; server 192.168.1.167:80; }

nginx五种负载均衡算法实现方式

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结果锁定在同一台机器上

nginx五种负载均衡算法实现方式

7、fairupstream test { server 192.168.1.160:80; server 192.168.1.167:80; fair;

nginx五种负载均衡算法实现方式
  • 如何使用nginx
  • welcome to nginx!解决办法
  • nginx如何使用
  • Nginx+FastCGI
  • 热门搜索
    素描图片大全 恐怖图片大全 羊肉饺子馅怎么做好吃 羊肾的做法大全 中国汉字大全 蛋糕图片大全 麻山药的做法大全 免费起名大全 栗子怎么做 婴儿受到惊吓怎么办