Skip to content
Foxipa
Code Completion 5 Challenges

Complete the config: Nginx Load Balancing

Fill in upstream pools, scheduling algorithms, failure handling, and keepalive.

Intermediate ~4 min read

Challenge 1

Balance by fewest active connections instead of round-robin.

nginx Your answer
upstream apps {
    ;
    server 10.0.0.1:8080;
    server 10.0.0.2:8080;
}

Press Ctrl⌘Enter to check your answer

Challenge 2

Keep each client IP on the same backend.

nginx Your answer
upstream apps {
    ;
    server 10.0.0.1:8080;
    server 10.0.0.2:8080;
}

Press Ctrl⌘Enter to check your answer

Challenge 3

Quarantine a flaky peer after three failures in thirty seconds.

nginx Your answer
upstream apps {
    server 10.0.0.4:8080 ;
}

Press Ctrl⌘Enter to check your answer

Challenge 4

Give the bigger machine twice the share of traffic.

nginx Your answer
upstream apps {
    server 10.0.0.1:8080 ;
    server 10.0.0.2:8080;
}

Press Ctrl⌘Enter to check your answer

Challenge 5

Hold 32 warm idle connections to the upstream.

nginx Your answer
upstream apps {
    server 10.0.0.1:8080;
     32;
}

Press Ctrl⌘Enter to check your answer