Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

What Is Round Robin? CPU Scheduling and Load Balancing

See how round robin gives CPU tasks a turn, trace three jobs through a time-slice example, and learn when it works for web requests.

Table of Contents

Round robin gives each eligible item a turn in a fixed order. In CPU scheduling, runnable tasks take turns using the processor for a limited time. In load balancing, successive requests can go to successive servers.

What is Round Robin? Concept, Features and Benefits Picture 1

How round-robin CPU scheduling works

The scheduler takes the first runnable task from a queue and lets it run for up to a time slice, also called a quantum. If the slice expires and the task still needs CPU time, it returns to the back of the runnable queue. A task that finishes leaves the queue. A task waiting for input or output becomes runnable again when the event it is waiting for completes.

What is Round Robin? Concept, Features and Benefits Picture 2

Round robin rotates through the runnable queue.

Example: Three jobs with a two-millisecond time slice

Suppose A needs 5 ms, B needs 3 ms, and C needs 1 ms. All are ready at time zero, and the example ignores the time spent switching tasks.

Time (ms)TaskResult at end of turn
0–2A3 ms left
2–4B1 ms left
4–5CFinished
5–7A1 ms left
7–8BFinished
8–9AFinished

Short slices let other tasks have a turn sooner, but increase the number of context switches. Long slices reduce that overhead and can make a newly runnable task wait longer. Equal turns also don’t guarantee that jobs will finish equally quickly.

How round robin distributes web requests

With three equivalent backends, a load balancer might send requests to A, B, C, then A again. This spreads request counts. If requests vary widely in cost, one backend can still end up doing more work than another. Weighted round robin gives some servers more turns. Least-connections routing uses the number of active connections to choose a backend. The Nginx load-balancing guide shows how those policies are used.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.