0
0
Nginxdevops~10 mins

Round-robin (default) in Nginx - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Round-robin (default)
Client Request Arrives
Select Next Server in List
Forward Request to Selected Server
Wait for Next Request
Back to Select Next Server
The load balancer receives each client request and forwards it to the next server in the list, cycling through servers evenly.
Execution Sample
Nginx
upstream backend {
    server backend1.example.com;
    server backend2.example.com;
}

server {
    location / { proxy_pass http://backend; }
}
This config sets up two backend servers and uses round-robin to distribute requests between them.
Process Table
Request NumberSelected ServerActionResult
1backend1.example.comForward requestRequest sent to backend1
2backend2.example.comForward requestRequest sent to backend2
3backend1.example.comForward requestRequest sent to backend1
4backend2.example.comForward requestRequest sent to backend2
5backend1.example.comForward requestRequest sent to backend1
💡 Cycle repeats after last server; round-robin continues indefinitely
Status Tracker
VariableStartAfter 1After 2After 3After 4After 5
Current Server Index010101
Key Moments - 2 Insights
Why does the server selection go back to backend1 after backend2?
Because round-robin cycles through the server list in order, after reaching the last server (backend2), it starts again from the first (backend1), as shown in execution_table rows 3 and 4.
Does round-robin consider server load or response time?
No, round-robin simply cycles through servers evenly without checking load or speed, so each request is sent to the next server in the list regardless of its state.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, which server handles the 4th request?
Abackend1.example.com
Bbackend2.example.com
Cbackend3.example.com
DNo server handles the 4th request
💡 Hint
Check the 'Selected Server' column for Request Number 4 in the execution_table.
At which request does the server selection index reset to 0?
AAfter Request 2
BAfter Request 3
CAfter Request 1
DAfter Request 5
💡 Hint
Look at the 'Current Server Index' in variable_tracker after each request.
If a third server is added, how will the selection change for the 6th request?
AIt will go back to backend1.example.com
BIt will skip the new server and select backend2.example.com
CIt will select the new third server
DIt will cause an error
💡 Hint
Round-robin cycles through all servers in order; adding a server adds it to the cycle.
Concept Snapshot
Round-robin load balancing in nginx cycles through backend servers in order.
Each new request goes to the next server in the list.
No server load or health checks affect selection by default.
Config example:
upstream backend { server backend1; server backend2; }
Requests rotate: backend1 -> backend2 -> backend1 -> ...
Full Transcript
Round-robin is the default method nginx uses to distribute client requests among backend servers. When a request arrives, nginx forwards it to the next server in the list, cycling through all servers evenly. This means the first request goes to the first server, the second to the second server, and so on. After the last server is used, nginx starts again from the first server. This cycle repeats indefinitely. The configuration defines the backend servers inside an upstream block. The proxy_pass directive sends requests to this upstream group. Round-robin does not consider server load or response time; it simply distributes requests evenly in order.