Nginx Load Balancer
Your team runs a small API behind an nginx reverse proxy, backed by two identical backend servers. Nginx currently sends all traffic to server-1, leaving server-2 completely unused, no requests reach it at all.
Your task is to configure nginx to distribute requests across both backends.
System Architecture
Your Task
Reconfigure nginx so that requests are balanced across both backends:
flask-app-1→ reports asserver-1flask-app-2→ reports asserver-2
You only need to edit the upstream flask_backend { ... } block in nginx.conf:
upstream flask_backend {
...
}
How to Apply Your Changes
- Open
nginx.confin the editor on the right, yournginxrepo is already cloned there. - Commit and push your changes from Source Control (or with
gitin the editor's terminal). - The platform will rebuild the nginx image and restart the service.
Success Criteria
When you submit, the Judge watches the next 60 seconds of live traffic. Both must pass:
- No Failed requests: no 4xx/5xx responses, timeouts, or refused connections.
- Both servers serving:
server-1andserver-2must each handle a steady share of traffic for the whole window.
Where to Monitor
Use the following tools to verify your fix:
Metrics: Before the fix, server-1 handles every request and server-2 sits flat at zero. After the fix, both climb together.
Logs: The most direct check. Each backend logs how many requests it served every 5 seconds, for example:
server-1: 8 requests in last 5s
Check the logs for both server-1 and server-2. Both should have a non-zero count. If server-2 keeps logging 0 requests, nginx is still sending all traffic to one backend.
Submit
Once the metrics show zero failures and sustained traffic to both backends, submit your solution.
- The default
upstreamblock lists only one server:flask-app-1:80. - The load-balancing strategy matters. Think about how round-robin,
least_conn, andip_hashbehave when traffic comes from a single client.