What does the weight parameter do in an NGINX upstream block using weighted round-robin?
Think about how NGINX balances traffic among servers with different capacities.
The weight parameter in NGINX's upstream configuration assigns a relative share of requests to each server. Servers with higher weights get more requests, allowing load balancing based on server capacity.
Which NGINX upstream configuration correctly implements weighted round-robin with server1 receiving twice the traffic of server2?
Look for the weight values assigned to each server.
Option A assigns weight=2 to server1 and weight=1 to server2, making server1 receive twice the requests compared to server2.
Given this upstream configuration:
upstream backend {
server 10.0.0.1 weight=3;
server 10.0.0.2 weight=1;
}After 8 requests, how many requests will each server have received?
Calculate requests proportional to weights: 3 parts vs 1 part.
The total weight is 4 (3+1). For 8 requests, server 10.0.0.1 gets (3/4)*8=6 requests, and 10.0.0.2 gets (1/4)*8=2 requests.
An NGINX server block uses weighted round-robin, but traffic is not distributed according to weights. Which misconfiguration is most likely causing this?
Check if weights differ between servers.
If all servers have the same weight or no weight, NGINX treats them equally, so weighted distribution does not occur.
In a weighted round-robin setup, what is the best practice to ensure traffic is not sent to unhealthy servers while maintaining weight distribution?
Consider automatic health checks and failover mechanisms.
Using max_fails and fail_timeout allows NGINX to automatically mark servers as down when they fail, preventing traffic from being sent to them while preserving weighted distribution among healthy servers.