The balancer: upmap and crush-compat
In the book: Chapter 19, Chapter 28
Lab
The balancer: upmap and crush-compat
CRUSH places the PGs, and some OSDs always end up with more than their share. Run a balancer round and see how upmap, with a few pg-upmap-items, or crush-compat, by changing the weight-set, reduces the deviation.
20.2 → 13.2max deviation (PGs), start → now
26–48fewest to most PGs on one OSD
20pg_upmap_items entries
10 / 20PGs moved: this round / all
Commands of round 2
ceph osd pg-upmap-items 1.20 6 11
ceph osd pg-upmap-items 1.2f 0 1
ceph osd pg-upmap-items 1.37 4 11
ceph osd pg-upmap-items 1.40 4 11
ceph osd pg-upmap-items 1.4b 4 11
ceph osd pg-upmap-items 1.4d 7 11
ceph osd pg-upmap-items 1.69 0 2
ceph osd pg-upmap-items 1.6d 0 2
ceph osd pg-upmap-items 1.74 7 9
ceph osd pg-upmap-items 1.7d 7 9Turning the balancer on
ceph osd set-require-min-compat-client luminous
ceph balancer mode upmap
ceph config set mgr mgr/balancer/upmap_max_deviation 5
ceph balancer on
ceph balancer evaltargeti = wi × size × pg_num / Σw · deviationi = PGsi − targeti · overfull: deviation > max_deviation · underfull: deviation < −max_deviation
upmap does not change CRUSH; it adds exceptions for single PGs, so it is precise and moves little data, but clients must be at least luminous. With a low pg_num even a perfect balance leaves a large relative deviation; fix pg_num first (chapter 7).
Follows:
src/osd/OSDMap.cc :: OSDMap::calc_pg_upmaps, calc_deviations, fill_overfull_underfull, try_drop_remap_overfull, try_drop_remap_underfull, try_pg_upmap, find_best_remap, _apply_upmapThe upmap calculation: overfull and underfull, dropping earlier upmaps, one pair per stepsrc/crush/CrushWrapper.cc :: try_remap_rule, _choose_type_stack, get_rule_weight_osd_mapFinding a replacement OSD in the same failure domainsrc/pybind/mgr/balancer/module.py :: do_upmap, do_crush_compat, calc_eval, calc_stats; upmap_max_deviation (5), upmap_max_optimizations (10)The mgr balancer module and its defaultssrc/common/options/global.yaml.in :: osd_calc_pg_upmaps_aggressively (true), osd_calc_pg_upmaps_local_fallback_retries (100), target_max_misplaced_ratio (0.05)The calc_pg_upmaps options and the misplaced limit