0
0
Nginxdevops~20 mins

Upstream blocks in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Upstream Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the effect of this upstream block configuration?
Given the following nginx upstream block, what will be the behavior when a client request is proxied to backend?
Nginx
upstream backend {
    server 192.168.1.10 weight=3;
    server 192.168.1.11 weight=1;
}

server {
    listen 80;
    location / {
        proxy_pass http://backend;
    }
}
ARequests will be distributed with 75% going to 192.168.1.10 and 25% to 192.168.1.11 based on weights.
BRequests will be sent only to 192.168.1.10 because it has the highest weight.
CRequests will be sent only to 192.168.1.11 because it has the lowest weight.
DRequests will be distributed equally between 192.168.1.10 and 192.168.1.11 regardless of weights.
Attempts:
2 left
💡 Hint
Weights in upstream blocks control the proportion of requests sent to each server.
Troubleshoot
intermediate
2:00remaining
Why does nginx fail to start with this upstream block?
Examine the following nginx configuration snippet. Why will nginx fail to start?
Nginx
upstream backend {
    server 192.168.1.10:8080;
    server 192.168.1.11:8080 max_fails=3 fail_timeout=30s;
    server 192.168.1.12:8080 max_fails=two fail_timeout=30s;
}

server {
    listen 80;
    location / {
        proxy_pass http://backend;
    }
}
AThe upstream block must have at least four servers defined.
BThe value 'two' for max_fails is invalid; it must be a number.
CThe fail_timeout value must be in milliseconds, not seconds.
DThe port 8080 is not allowed in upstream blocks.
Attempts:
2 left
💡 Hint
Check the data types of parameters in the upstream block.
Configuration
advanced
2:00remaining
Which upstream block configuration enables session persistence using IP hash?
Select the correct nginx upstream block configuration that ensures requests from the same client IP always go to the same backend server.
A
upstream backend {
    ip_hash;
    server 192.168.1.10;
    server 192.168.1.11;
}
B
upstream backend {
    least_conn;
    server 192.168.1.10;
    server 192.168.1.11;
}
C
upstream backend {
    server 192.168.1.10;
    server 192.168.1.11;
    sticky;
}
D
upstream backend {
    server 192.168.1.10;
    server 192.168.1.11;
    hash $remote_addr;
}
Attempts:
2 left
💡 Hint
Look for the directive that explicitly enables IP-based session persistence.
Best Practice
advanced
2:00remaining
What is the recommended way to mark a backend server as temporarily unavailable in an upstream block?
You want nginx to stop sending requests to a backend server temporarily without removing it from the configuration. Which is the best way to do this?
ARemove the server line and reload nginx configuration.
BComment out the server line in the upstream block.
CUse the 'down' parameter in the server line inside the upstream block.
DSet the server weight to zero.
Attempts:
2 left
💡 Hint
Look for a parameter that disables a server without deleting its config.
🔀 Workflow
expert
3:00remaining
Order the steps to safely update an nginx upstream block without dropping client connections
You need to update the list of backend servers in an nginx upstream block without interrupting active client connections. What is the correct order of steps?
A3,1,2,4
B2,1,3,4
C1,3,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint
Think about safe config changes and validation before applying.