Definition · Hash partitioningUnder hash partitioning the shard of a key k is h(k) mod N for a hash function h. Keys near each other in the original key space are scattered, so range scans become expensive and the placement stops depending on what the keys mean. The occupancy of a shard is the number of keys assigned to it, and its mean over the fleet is m/N whatever the hash does.
The claim under examination is the everyday one: that hashing spreads keys evenly. It spreads them uniformly at random, which is a different sentence. Uniform means no shard is favoured; it does not mean no shard is fuller, and the whole of this course's imbalance arithmetic lives in that distinction.
The placements here come from a seeded generator printed on the page, so “random” is reproducible: the stream is x → 16 807·x mod (2³¹ − 1), with the modulus prime on purpose. The generator used elsewhere on this library's paths has a modulus of 2³¹, and the low bits of such a stream are periodic — x mod 4 cycles 0, 1, 2, 3 for ever. Taking that stream modulo 8 or 16 fills the shards perfectly level, which would demonstrate the opposite of this lesson's claim. The constants are on the page so you can check which generator drew your placement.
m = 1 200 keys N = 12 shards seed 7
mean = 1 200/12 = 100 exact
fullest shard = 122 counted
emptiest = 82 counted
max/mean = 122 × 12/1 200 = 61/50 = 1.220
excess = 122 − 100 = 22 = 2.20 × √100
Why the excess is a square-root term
Raise the load and max/mean improves: the same 12 shards with 12 000 keys came out at 1.046 and with 120 000 keys at 1.018. It is tempting to read that as the imbalance going away. It is not going away — it is being divided by a larger mean. The absolute excess over the mean went from 22 keys to 46 keys to 182 keys as the mean went from 100 to 1 000 to 10 000, which is growth like √mean rather than a constant.
That is why the lab prints the excess in units of √mean rather than as a percentage. Measured that way it stays a small number of order one — 2.20, 1.45, 1.82 on those three runs — instead of appearing to shrink. It is a noisy small number, and reseeding shows it moving between 1.20 and 2.20 on the default placement, which is the honest picture: a term of a fixed order of magnitude, not a constant.
Example · What this costs a capacity planProvision every shard for the mean and the fullest one is over its allocation by 22% on the default placement. Provision every shard for the fullest and 11 of the 12 are over-bought. The usable answer is neither: size for a maximum you have measured across several seeds — 1.170 on average and 1.220 at worst here — and treat the excess as a cost of hashing rather than as a defect to be engineered away.
The result this lesson measures and does not prove
When the number of keys equals the number of shards, the maximum occupancy is Θ(log n / log log n). That result is stated, not proved — not here and nowhere else in this library. Its proof needs Chernoff bounds, which the Algorithms path excludes from its own scope, so no lesson anywhere establishes it. What this lesson does is measure the maximum on placements you choose.
Two related quantities are computed exactly, and they are computed elsewhere. “Balls in Bins and the Birthday Bound”, on the Randomised Algorithms course of the Algorithms path, derives the expected number of colliding pairs as n(n − 1)/2m and the expected number of empty bins as m(1 − 1/m)ⁿ, both by linearity of expectation and both exact. Those are the expectations this lesson does not compute; the maximum is the thing it measures. The seeded generator itself is “Hashing and Pseudorandom Numbers” on the Discrete Mathematics path.
Keep the three statuses apart when you quote a figure from this course. The mean is exact. The maximum on a given placement is measured and reproducible. The growth rate of the maximum is stated. A design review that treats the third as though it had the standing of the first is the failure this paragraph exists to prevent.