0
0
Nginxdevops~20 mins

Weighted round-robin in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Weighted Round-Robin Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Weighted Round-Robin in NGINX

What does the weight parameter do in an NGINX upstream block using weighted round-robin?

AIt defines the timeout duration for requests to a server.
BIt sets the maximum number of simultaneous connections allowed to a server.
CIt assigns a relative load share to each server, so servers with higher weights receive more requests.
DIt specifies the priority order in which servers are tried sequentially.
Attempts:
2 left
💡 Hint

Think about how NGINX balances traffic among servers with different capacities.

Configuration
intermediate
2:00remaining
Identify the Correct Weighted Round-Robin Configuration

Which NGINX upstream configuration correctly implements weighted round-robin with server1 receiving twice the traffic of server2?

A
upstream backend {
    server server1.example.com weight=2;
    server server2.example.com weight=1;
}
B
upstream backend {
    server server1.example.com weight=1;
    server server2.example.com weight=2;
}
C
upstream backend {
    server server1.example.com max_fails=2;
    server server2.example.com max_fails=1;
}
D
upstream backend {
    server server1.example.com;
    server server2.example.com;
}
Attempts:
2 left
💡 Hint

Look for the weight values assigned to each server.

💻 Command Output
advanced
2:00remaining
Output of NGINX Weighted Round-Robin Load Distribution

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?

A10.0.0.1: 3 requests, 10.0.0.2: 5 requests
B10.0.0.1: 6 requests, 10.0.0.2: 2 requests
C10.0.0.1: 4 requests, 10.0.0.2: 4 requests
D10.0.0.1: 8 requests, 10.0.0.2: 0 requests
Attempts:
2 left
💡 Hint

Calculate requests proportional to weights: 3 parts vs 1 part.

Troubleshoot
advanced
1:30remaining
Troubleshooting Weighted Round-Robin Misconfiguration

An NGINX server block uses weighted round-robin, but traffic is not distributed according to weights. Which misconfiguration is most likely causing this?

AAll servers have the same weight value or no weight specified.
BThe <code>max_fails</code> parameter is set too high.
CThe <code>keepalive</code> directive is missing.
DThe <code>proxy_pass</code> directive is outside the server block.
Attempts:
2 left
💡 Hint

Check if weights differ between servers.

Best Practice
expert
2:30remaining
Best Practice for Weighted Round-Robin with Dynamic Server Health

In a weighted round-robin setup, what is the best practice to ensure traffic is not sent to unhealthy servers while maintaining weight distribution?

ASet all server weights to zero when a server is unhealthy.
BManually remove unhealthy servers from the upstream block and reload NGINX configuration.
CDisable weighted round-robin and use simple round-robin instead.
DUse <code>max_fails</code> and <code>fail_timeout</code> to mark servers as down and exclude them from load balancing temporarily.
Attempts:
2 left
💡 Hint

Consider automatic health checks and failover mechanisms.