nginx负载均衡 upstram server的简单用法

场景

  • 负载均衡

参考资料

用法

语法

Syntax: upstream name { … }
Default: —
Context: http

Defines a group of servers. Servers can listen on different ports. In addition, servers listening on TCP and UNIX-domain sockets can be mixed.

例子

upstream backend {
server backend1.example.com weight=5;
server 127.0.0.1:8080 max_fails=3 fail_timeout=30s;
server unix:/tmp/backend3;
server backup1.example.com backup;
}

7个请求5个会发送到backend1.example.com, 一个发送到了127.0.0.1:8080, 一个发送到了unix:/tmp/backend3 ; 在其他服务均不可以使用的使用的时候,请求才会发送到backup1.example.com

详细设置

Syntax: server address [parameters];
Default: —
Context: upstream

weight=number

设置权重, 默认1

max_conns=number

server同时活跃的连接数,默认是0,不限制

max_fails=number

在尝试number次和server通信失败后,认定server不可以使用

fail_timeout=time

当认定server不可以使用,则time秒内不可以重新连接server

backup

marks the server as a backup server. It will be passed requests when the primary servers are unavailable.

down

标记server永久不可以使用
其他参数见官方文档

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值