Why Smooth Weighted Round Robin Works: The Math Behind Balanced Load Distribution

This article explains the smooth weighted round robin algorithm, contrasts it with the non‑smooth version, walks through step‑by‑step examples for a 5:1:1 server weight scenario, and provides mathematical proofs of both weight correctness and smoothness, including references to the original source.

IT Services Circle
IT Services Circle
IT Services Circle
Why Smooth Weighted Round Robin Works: The Math Behind Balanced Load Distribution

Non-smooth weighted round robin

In a non‑smooth weighted round robin, servers with higher weight are selected consecutively, leading to bursts of traffic on the busy node and idle periods for others.

Non‑smooth weighted round robin illustration
Non‑smooth weighted round robin illustration

Smooth weighted round robin

The smooth algorithm maintains two weights for each node: a static weight and a dynamic currentWeight (initially 0). For each request it adds the static weight to currentWeight of every node, selects the node with the highest currentWeight, then subtracts the total weight sum from that node’s currentWeight. This produces a smooth distribution.

weight – constant configuration value

currentWeight – changes each round

Step‑by‑step example (weights A:B:C = 5:1:1)

First request: after adding weights, currentWeight = [5,1,1]; A is selected, then A’s currentWeight becomes 5‑7 = -2. Resulting weights: [-2,1,1].

First request steps
First request steps

Second request: add weights → [3,2,2]; A still highest, selected, then A’s currentWeight = 3‑7 = -4[-4,2,2].

Second request steps
Second request steps

Continuing this process for the third, fourth, … requests yields the selection order A → A → B → A → C → A → A, after which the pattern repeats, perfectly matching the 5:1:1 weight ratio without long bursts.

Selection order after several rounds
Selection order after several rounds

Mathematical proof of weight correctness

Let there be n nodes with weights w_i and total weight S = Σw_i. The algorithm starts with all currentWeight = 0. After each full round the sum of currentWeight values is 0. By induction, after S selections each node i has been chosen exactly w_i times, proving that the algorithm respects the configured weights.

Proof of smoothness

Because after a node is selected its currentWeight is reduced by S, it cannot be selected again until other nodes have accumulated enough weight to exceed it. Therefore the algorithm never selects the same node consecutively more than its weight permits, guaranteeing a smooth distribution.

Pseudocode

for each request:
    for node in nodes:
        node.currentWeight += node.weight
    selected = node with max currentWeight
    selected.currentWeight -= totalWeight

One more thing – source reference

The original article was removed, but an archived copy is available at https://web.archive.org/web/20210918075426/https://tenfy.cn/2018/11/12/smooth-weighted-round-robin/ .

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Distributed Systemsalgorithmload balancingproofsmooth weighted round robin
IT Services Circle
Written by

IT Services Circle

Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.