Nginx - load balance

Intro

使用nginx进行负载均衡

Config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
http {
upstream myapp1 {
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
}

server {
listen 80;

location / {
proxy_pass http://myapp1;
}
}
}

三种负载方式

  • round-robin
  • least-connected
  • ip-hash

Reference

http://nginx.org/en/docs/http/load_balancing.html