Nginx Load Balancer

All challenges

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

HTTP :80proxy_passClient SimulatorNGINXServer 1Server 2

Your Task

Reconfigure nginx so that requests are balanced across both backends:

  • flask-app-1 → reports as server-1
  • flask-app-2 → reports as server-2

You only need to edit the upstream flask_backend { ... } block in nginx.conf:

nginx
upstream flask_backend {
    ...
}

How to Apply Your Changes

  1. Open nginx.conf in the editor on the right, your nginx repo is already cloned there.
  2. Commit and push your changes from Source Control (or with git in the editor's terminal).
  3. 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-1 and server-2 must 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:

text
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 upstream block lists only one server: flask-app-1:80.
  • The load-balancing strategy matters. Think about how round-robin, least_conn, and ip_hash behave when traffic comes from a single client.