轮询、hash、最小连接数、权重
轮询
分配相同的任务,是NGINX的默认策略
加权
权重越高,任务越高
upstream tomcats {
server 192.168.1.173:8080 weight=2;
server 192.168.1.190:8080 weight=5;
server 192.168.1.174:8080 weight=5;
server 192.168.1.175:8080 weight=1;
}
ip_hash
upstream tomcats {
ip_hash;
server 192.168.1.173:8080;
server 192.168.1.174:8080 down;
server 192.168.1.175:8080;
}
一致性HASH
url_hash
upstream tomcats {
hash $request_uri;
server 192.168.244.1:8080;
server 192.168.244.2:8080;
server 192.168.244.3:8080;
server 192.168.244.4:8080;
}
leash_conn 最少连接数
upstream tomcats{
leash_conn;
server localhost:8081;
server localhost:8082;
server localhost:8083;
}