When configuring NGINX with multiple server entries, one can configure a round-robin algorithm for distributing load. NGINX offers the weight to indicate how weight is distributed. For ex.:
upstream backend {
 server backend1.example.com       weight=5;
 server backend2.example.com:8080  weight=1;
}
server {
    location / {
        proxy_pass http://backend;
    }
}
Question is: What is the maximum value assignable to weight?
My problem is that I have encountered a configuration with 2 server entries one with a weight value of 2000000000 (2 billion) and one with a value of 1. The intention was to have all traffic directed on the first server as temporarily the second one was down. However after far less than 2 bil requests users got error because they were directed to the second server.
You should use health checking for that usage, not weight.
You have 2 options:
Using built in nginx layer 3 healthchecks:
Using max_fails, fail_timeout and even backup directive.
backup: marks the server as a backup server. It will be passed requests when the primary servers are unavailable.
Using community modules like nginx_upstream_check_module
This module enables layer 7 healthchecks, This is the recommended way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With