Cấu hình load balancing health check cho nginx.
File defaul nginx load balancing :
http { upstream myapp1 { server srv1.example.com; server srv2.example.com; server srv3.example.com; } server { listen 80; location / { proxy_pass http://myapp1; } } }
Ví dụ bạn có file nginx như sau:
upstream mywebsite1 {
least_conn;
server xxx.xxx.xxx.20 weight=1 max_fails=3 fail_timeout=15s;
server xxx.xxx.xxx.21 weight=1 max_fails=3 fail_timeout=15s;
}
Cấu hình trên là cấu hình load balancer cho nginx với max_fail = 3 , nghĩa là với request thứ 7 khi 1 server bị down thì từ request thứ 7 trở đi ,tất cả các request được trỏ về server còn sống.
Nên để cấu hình heath check bạn cấu hình max_fail = 1 , nghĩa là từ request thứ 3 trở đi đều redirect về server live nếu 1 trong 2 server live die
Chi tiết www.manageitservice247.com
Nhận xét
Đăng nhận xét