Misplaced Pages

Weighted round robin

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Scheduling algorithm for tasks or data flows

Weighted round robin (WRR) is a network scheduler for 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 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. The main ones are the classical 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 n {\displaystyle n} input queues, q 1 , . . . , q n {\displaystyle q_{1},...,q_{n}} . To each queue q i {\displaystyle q_{i}} is associated w i {\displaystyle w_{i}} , a positive integer, called the weight. The WRR scheduler has a cyclic behavior. In each cycle, each queue q i {\displaystyle q_{i}} has w i {\displaystyle w_{i}} 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 q i {\displaystyle q_{i}} is selected, the scheduler will send packets, up to the emission of w i {\displaystyle w_{i}} packet or the end of queue.

Constant and variables: 
    const N             // Nb of queues 
    const weight  // weight of each queue
    queues        // queues
    i                   // queue index
    c                   // packet counter
Instructions:
while true do 
    for i in 1 .. N do
        c := 0
        while (not queue.empty) and (c<weight) do
            send(queue.head())
            queue.dequeue()
            c:= c+1

Interleaved WRR

Let w m a x = max { w i } {\displaystyle w_{max}=\max\{w_{i}\}} , be the maximum weight. In IWRR, each cycle is split into w m a x {\displaystyle w_{max}} rounds. A queue with weight w i {\displaystyle w_{i}} can emit one packet at round r {\displaystyle r} only if r w i {\displaystyle r\leq w_{i}} .

Constant and variables: 
    const N             // Nb of queues 
    const weight  // weight of each queue
    const w_max
    queues        // 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.empty) and (weight >= r) then
                send(queue.head())
                queue.dequeue()

Example

Example of scheduling for CWRR and IWRR

Consider a system with three queues q 1 , q 2 , q 3 {\displaystyle q_{1},q_{2},q_{3}} and respective weights w 1 = 5 , w 2 = 2 , w 3 = 3 {\displaystyle w_{1}=5,w_{2}=2,w_{3}=3} . Consider a situation where there 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 q 1 {\displaystyle q_{1}} and transmits the five packets at head of queue,A,B,C,D,E (since w 1 = 5 {\displaystyle w_{1}=5} ), then it selects the second queue, q 2 {\displaystyle q_{2}} , and transmits the two packets at head of queue, U,V (since w 2 = 2 {\displaystyle w_{2}=2} ), 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 q 1 {\displaystyle q_{1}} are transmitted, followed by W from q 2 {\displaystyle q_{2}} .

With interleaved WRR, the first cycle is split into 5 rounds (since m a x ( w 1 , w 2 , w 3 ) = 5 {\displaystyle max(w_{1},w_{2},w_{3})=5} ). In the first one (r=1), one packet from each queue is sent (A,U,X), in the second round (r=2), another packet from each queue is also sent (B,V,Y), in the third round (r=3), only queues q 1 , q 3 {\displaystyle q_{1},q_{3}} are allowed to send a packet ( w 1 >= r {\displaystyle w_{1}>=r} , w 2 < r {\displaystyle w_{2}<r} and w 3 >= r {\displaystyle w_{3}>=r} ), but since q 3 {\displaystyle q_{3}} is empty, only C from q 1 {\displaystyle q_{1}} is sent, and in the fourth and fifth rounds, only D,E from q 1 {\displaystyle q_{1}} 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 n {\displaystyle n} active tasks, they are scheduled in a cyclic way, each task τ i {\displaystyle \tau _{i}} gets w i {\displaystyle w_{i}} 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 and IWRR are an approximation of Generalized processor sharing: a queue q i {\displaystyle q_{i}} will receive a long term part of the bandwidth equals to w i j = 1 n w j {\displaystyle {\frac {w_{i}}{\sum _{j=1}^{n}w_{j}}}} (if all queues are active) 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 s i {\displaystyle s_{i}} is known for every queue q i {\displaystyle q_{i}} , each queue will receive a long term part of the bandwidth equals to s i × w i j = 1 n s j × w j {\displaystyle {\frac {s_{i}\times w_{i}}{\sum _{j=1}^{n}s_{j}\times w_{j}}}} . If the objective is to give to each queue q i {\displaystyle q_{i}} a portion ρ i {\displaystyle \rho _{i}} of link capacity (with i = 1 n ρ i = 1 {\displaystyle \sum _{i=1}^{n}\rho _{i}=1} ), one may set w i = ρ i s i {\displaystyle w_{i}={\frac {\rho _{i}}{s_{i}}}} .

Since IWRR has smaller per class bursts than WRR, it implies smaller worst-case delays.

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 (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).

See also

References

  1. ^ Katevenis, M.; Sidgiropoulos, S.; Courcoubetis, C. (1991). "Weighted round-robin cell multiplexing in a general-purpose ATM switch chip". IEEE Journal on Selected Areas in Communications. 9 (8): 1265–1279. doi:10.1109/49.105173. ISSN 0733-8716.
  2. ^ Chaskar, H.M.; Madhow, U. (2003). "Fair scheduling with tunable latency: A round-robin approach". IEEE/ACM Transactions on Networking. 11 (4): 592–601. doi:10.1109/TNET.2003.815290. ISSN 1063-6692. S2CID 8010108.
  3. Brahimi, B.; Aubrun, C.; Rondeau, E. (2006). "Modelling and Simulation of Scheduling Policies Implemented in Ethernet Switch by Using Coloured Petri Nets". 2006 IEEE Conference on Emerging Technologies and Factory Automation. pp. 667–674. doi:10.1109/ETFA.2006.355373. ISBN 0-7803-9758-4. S2CID 6089006.
  4. F. Baker; R.Pan (May 2016). "2.2.2. Round-Robin Models". On Queuing, Marking, and Dropping (Technical report). IETF. RFC 7806.
  5. Semeria, Chuck (2001). Supporting Differentiated Service Classes: Queue Scheduling Disciplines (PDF) (Report). pp. 15–18. Retrieved May 4, 2020.
  6. Beaulieu, Alain (Winter 2017). "Real Time Operating Systems – Scheduling & Schedulers" (PDF). Retrieved May 4, 2020.
  7. United States 20190266019, Philip D. Hirsch, "Task Scheduling Using Improved Weighted Round Robin Techniques", published August 29, 2019 
  8. Fall, Kevin (April 29, 1999). "EECS 122, "Introduction to Communication Networks", Lecture 27, "Scheduling Best-Effort and Guaranteed Connections"". Retrieved May 4, 2020.
  9. Tabatabaee, Seyed Mohammadhossein; Le Boudec, Jean-Yves; Boyer, Marc (September 22–24, 2020). "Interleaved Weighted Round-Robin: A Network Calculus Analysis". Proc. of the 32nd Int. Teletraffic Congress (ITC 32). arXiv:2003.08372. doi:10.1109/ITC3249928.2020.00016.
Category: