nginx负载均衡

RR

upstream test{
  server localhost:8080;
  server localhost:8081;
}
server{
  listen 80;
  server_name localhost;
  client_max_body_size 1024M;
  
  location / {
    proxy_pass http://test;
    proxy_set_header Host $host:$server_port;
  }
}

权重

upstream test{
  server localhost:8080 weight=9;
  server localhost:8081 weight=1;
}

ip_hash

upstream test{
  ip_hash;
  server localhost:8080;
  server localhost:8081;
}

fair

upstream test{
  fair;
  server localhost:8080;
  server localhost:8081;
}

url_hash

upstream test{
  hash $request_uri;
  hash_method crc32;
  server localhost:8080;
  server localhost:8081;
}

fair和url_hash需要第三方模块才能使用