Skip to content
CoreSource checked

Weighted Round Robin

Cycles through queues while giving higher-weight queues more service opportunities.

Quick Facts

Compact metadata for implementation and discovery.

Category
Scheduling
Difficulty
Beginner
Family
Queue Scheduling
Tier
Core
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
3
Code example
Ready
Visualization
Ready

Overview

Weighted Round Robin extends round robin by assigning each queue a weight that controls how many jobs or bytes it can serve per cycle.

Core Concepts

queue cycleservice weightproportional sharefairness

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(1)

Average

O(n)

Worst

O(n)

Space

O(queues)

When to Use

  • Use when simple proportional service is needed across queues or tenants.
  • Use when network scheduling is a central requirement.

When Not to Use

  • Avoid when job sizes vary widely and precise fairness is required.
  • Avoid when task priorities, durations, or fairness goals are unknown or unstable.

What It Does

  • Maintains multiple queues
  • Cycles through queues
  • Serves each queue according to weight

Use Cases

  • Network scheduling
  • Load balancers
  • Shared worker pools

Inputs

  • Queues
  • Weights
  • Jobs or packets

Outputs

  • Weighted service order

Key Formulas (1)

Service share

sharei = weighti / ∑(weights)
share_i = weight_i / sum(weights)

Describes the intended long-run share for each queue.

Pseudocode

  1. 1.Assign a weight to each queue
  2. 2.Visit queues in cyclic order
  3. 3.Serve up to the queue's weight from each non-empty queue
  4. 4.Repeat while work remains

Canonical Example

Input
weights A:2, B:1
Output
order = A, A, B, A, A, B
Explanation
Queue A receives roughly twice as many service slots as B.

Implementation Notes

  • Decide whether weight means jobs, bytes, time, or another service unit.
  • Track waiting time, service time, and queue state separately.
  • Keep a tiny example with expected output beside the implementation.
  • State whether the policy is preemptive and what fairness, latency, or deadline objective it optimizes.

Common Pitfalls

  • Weights based on job count can be unfair when job costs differ.
  • A locally fair rule can still create starvation or poor latency under skewed workloads.
  • Not defining boundary, empty, or degenerate inputs before implementation.
  • Ignoring preemption cost, release times, or starvation can make a schedule look correct only in toy cases.

Interactive Mechanism Walkthrough

Graph Frontier & Edge Relaxation

Show a scheduler cycling through queues where high-weight queues get extra turns.

Weighted Round Robin mechanism walkthrough step 1 of 4suvwxt
Step 1 of 4: Assign a weight to each queue
timeline

Notes

Large jobs can still create short-term unfairness if weights count jobs instead of work size.

Sources (1)

What each reference supports for this entry.

Operating System Concepts

Book

Operating-systems reference for Weighted Round Robin CPU scheduling policy, ready-queue ordering, and preemption behavior.

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Weighted round robin extends round robin by assigning different service weights to queues.

Tags

SchedulingQueueLoad Balancing