Weighted round robin


Weighted round robin is a scheduling algorithm used in networks to schedule data flows, but also used to schedule processes.
Weighted round robin is a generalisation of Round-robin scheduling. It serves a set of queues or tasks. Whereas round-robin cycles over the queues/tasks and gives one service opportunity per cycle, weighted round robin offers to each a fixed number of opportunities, the work weight, set at configuration. It then allow to influence the portion of capacity received by each queue/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.
There exists several variations of WRR. The main ones are the classicall WRR, and the Interleaved WRR.

Algorithm

Principles

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 input queues,. To each queue is associated, a positive integer, called the weight. The WRR scheduler has a cyclic behavior. In each cycle, each queue has emissions opportunities.
The different WRR algorithms differ on the distributions of these opportunities in the cycle.

Classical WRR

In classical WRR
the scheduler cycles over the queues. When a queue is selected, the scheduler will send packets, up to the emission of packet or the end of queue.

Interleaved WRR

Let, be the maximum weight. In IWRR, each cycle is split into rounds. A queue with weight can emit one packet at round only if.

Example

Consider a system with three queues and respective weights. Consider a situation where they are 7 packets in the first queue, A,B,C,D,E,F,G, 3 in the second queue, U,V,W and 2 in the third queue X,Y. Assume that there is no more packet arrival.
With classical WRR, in the first cycle, the scheduler first selects and transmits the five packets at head of queue,A,B,C,D,E, then it selects the second queue, , and transmits the two packets at head of queue, U,V, and last it selects the third queue, which has a weight equals to 3 but only two packets, so it transmits X,Y. Immediately after the end of transmission of Y, the second cycle starts, and F,G from are transmitted, followed by W from.
With interleaved WRR, the first cycle is split into 5 rounds. In the first one, one packet from each queue is sent, in the second round, another packet from each queue is also sent, in the third round, only queues are allowed to send a packet, but since is empty, only C from is sent, and in the fourth and fifth rounds, only D,E from are sent. Then starts the second cycle, where F,W,G are sent.

Task scheduling

Task or process scheduling can be done in WRR in a way similar to packet scheduling: when considering a set of active tasks, they are scheduled in a cyclic way, each task gets quantum or slice of processor time

Properties

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 is an approximation of Generalized processor sharing: a queue will receive a long term part of the bandwidth equals to while GPS serves infinitesimal amounts of data from each nonempty queue and offer this part on any interval.
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 is known for every queue, each queue will receive a long term part of the bandwidth equals to . If the objective is to give to each queue a portion of link capacity, one may set .

Limitations and improvements

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. 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, in order 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.