# Failure-domain capacity: exact worked examples

These are fictional capacity budgets in TiB, not a measured Ceph cluster.
Python 3 standard library only. Put model.py and test_model.py together:

```sh
python3 -B model.py
python3 -B -m unittest -v test_model.py
```

## Model and derivation

Let D eligible domains have nonnegative capacity budgets c_i. Each stripe uses n
distinct domains, one equal-sized shard in each. Let X be total data per shard
position. A replicated pool stores X logical TiB and nX raw TiB. A k+m code
stores kX logical TiB with n=k+m. Data is arbitrarily divisible.

Any chosen j domains hold at most jX. The other domains must hold at least
(n-j)X. Excluding the j largest budgets leaves the smallest remaining sum S_j,
so X <= S_j/(n-j), for j=0,...,n-1. The implementation takes the smallest bound.
Fewer than n domains gives zero.

Why is it attainable in this fractional model? At the bound, choose domain loads
l_i between zero and min(c_i,X), summing to nX. Such loads exist because
sum min(c_i,X) >= nX. Normalized loads l_i/X lie in [0,1] and sum to integer n.
If two coordinates are fractional, move mass between them in both directions
until one reaches an endpoint. The original vector is a convex combination of
the two resulting vectors. Repeating gives vectors with exactly n ones:
legal stripe placements. This proves sufficiency without assuming a particular
CRUSH map. X=0 is immediate. Sorting costs O(D log D); the bound scan costs O(n).

## Results and independent checks

The 60/20/20 example has X=20. Expanding only 60 to 120 leaves X unchanged.
Adding a fourth 20 gives X=30. A constructive placement writes 10 TiB to each
triple ABC, ABD and ACD: domain loads become 30/20/20/20.
Increasing both small domains instead gives X=40 for 60/40/40.

The test oracle recursively enumerates legal integer one-unit stripe allocations,
independently of the formula, for all sorted capacity vectors with one through
five domains and capacities 0 through 3. It compares floor(X) with that optimum.
Separate denominator-scaled examples check fractional optima, alongside input,
permutation, scale and explicit placement controls.

For 60/20/20/20, a chosen 95% occupancy budget yields X=28.5. After any one domain
is removed, a chosen 90% survivor budget yields X=18. These are endpoint bounds,
not proof that online backfill can realize that endpoint without temporary space,
additional failures or unavailable source shards.

## Sources and scope

- Weil, Brandt, Miller and Maltzahn, CRUSH, SC 2006, sections 3.1-3.3:
  https://ceph.io/assets/pdfs/weil-crush-sc06.pdf
  Establishes hierarchical placement and distinct-target rules; it does not
  supply the worked capacities above or document later straw2 behavior.
- Ceph Umbrella documentation, FD Calc, accessed 2026-11-28:
  https://docs.ceph.com/en/umbrella/rados/operations/fdcalc/
  Describes placement-stranded capacity and the capacity-feasibility inequality.
- Ceph Squid Monitor Config Reference, Storage Capacity, accessed 2026-11-28:
  https://docs.ceph.com/en/squid/rados/configuration/mon-config-ref/#storage-capacity
  Supports the distinction between full and backfill thresholds. The example
  ratios are explicit inputs, not a claim about an operator's actual settings.

No Ceph source is copied. The calculation and proof are a Hesela worked
derivation of the stated idealized model, not a new placement algorithm.
No randomness, fitted parameters, empirical uncertainty or hardware execution.
Excluded: fixed PG assignments, unequal shard sizes, multiple pools, per-device
skew, extra topology constraints, metadata, compression and repair scheduling.
The capacity inputs are budgets dedicated to this pool, not live free-space
counters to which an empty-pool formula can be applied uncritically.
