超级详细的Nginx负载均衡配置 不看是你的损失哦~原创
2年前
409335
什么是负载均衡
负载均衡配置
负载均衡策略
-
轮循
upstream api/{
server localhost:1000;
server localhost:1001;
}
在这种策略下,Nginx会按照时间顺序将请求转发到不同的服务器上,如果某一台机器down掉了,会自动从负载策略中剔除,下次不再轮询
-
权重
upstream api/ {
server localhost:1000 weight=10;
server localhost:1001 weight=20;
}
-
iphash
upstream api/ {
ip_hash;
server localhost:1000 weight=10;
server localhost:1001 weight=20;
}
-
最少连接
upstream api {
least_conn;
server localhost:1000 weight=10;
server localhost:1001 weight=20;
}
点赞收藏
分类:
