Weighted round robin (WRR) is a network scheduler for data flows, but also used to schedule processes.
Weighted round robin[1] is a generalisation of round-robin scheduling. It serves a set of queues or tasks. Whereas round-robin cycles over the queues or tasks and gives one service opportunity per cycle, weighted round robin offers to each a fixed number of opportunities, as specified by the configured weight which serves to influence the portion of capacity received by each queue or task. In computer networks, a service opportunity is the emission of one packet, if the selected queue is non-empty.
If all packets have the same size, WRR is the simplest approximation of generalized processor sharing (GPS). Several variations of WRR exist.[2] The main ones are the classical WRR, and the interleaved WRR.
WRR is presented in the following as a network scheduler. It can also be used to schedule tasks in a similar way.
A weighted round-robin network scheduler has
n
q1,...,qn
qi
wi
qi
wi
The different WRR algorithms differ on the distributions of these opportunities in the cycle.
In classical WRR[3] [4] the scheduler cycles over the queues. When a queue
qi
wi
Constant and variables: const N // Nb of queues const weight[1..N] // weight of each queue queues[1..N] // queues i // queue index c // packet counter Instructions: while true do for i in 1 .. N do c := 0 while (not queue[i].empty) and (c |
Let
wmax=max\{wi\}
wmax
wi
r
r\leqwi
Constant and variables: const N // Nb of queues const weight[1..N] // weight of each queue const w_max queues[1..N] // queues i // queue index r // round counter Instructions: while true do for r in 1 .. w_max do for i in 1 .. N do if (not queue[i].empty) and (weight[i] >= r) then send(queue[i].head) queue[i].dequeue |
Consider a system with three queues
q1,q2,q3
w1=5,w2=2,w3=3
With classical WRR, in the first cycle, the scheduler first selects
q1
w1=5
q2
w2=2
q1
q2
With interleaved WRR, the first cycle is split into 5 rounds (since
max(w1,w2,w3)=5
q1,q3
w1>=r
w2<r
w3>=r
q3
q1
q1
Task or process scheduling can be done in WRR in a way similar to packet scheduling: when considering a set of
n
\taui
wi
Like round-robin, weighted round robin scheduling is simple, easy to implement, work conserving and starvation-free.
When scheduling packets, if all packets have the same size, then WRR and IWRR are an approximation of Generalized processor sharing:[8] a queue
qi
wi | |||||||||
|
If the queues have packets of variable length, the part of the bandwidth received by each queue depends not only on the weights but also of the packets sizes.
If a mean packets size
si
qi
si x wi | |||||||||
|
qi
\rhoi
n | |
\sum | |
i=1 |
\rhoi=1
wi=
\rhoi | |
si |
Since IWRR has smaller per class bursts than WRR, it implies smaller worst-case delays.[9]
WRR for network packet scheduling was first proposed by Katevenis, Sidiropoulos and Courcoubetis in 1991, specifically for scheduling in ATM networks using fixed-size packets (cells). The primary limitation of weighted round-robin queuing is that it provides the correct percentage of bandwidth to each service class only if all the packets in all the queues are the same size or when the mean packet size is known in advance. In the more general case of IP networks with variable size packets, to approximate GPS the weight factors must be adjusted based on the packet size. That requires estimation of the average packet size, which makes a good GPS approximation hard to achieve in practice with WRR.
Deficit round robin is a later variation of WRR that achieves better GPS approximation without knowing the mean packet size of each connection in advance. More effective scheduling disciplines were also introduced which handle the limitations mentioned above (e.g. weighted fair queuing).