The Comprehensive Ceph Guide
فارسیGet started

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
510osd.0 (host1, 4 TB): 30 PGs, target 25.60osd.1 (host1, 4 TB): 26 PGs, target 25.61osd.2 (host1, 4 TB): 26 PGs, target 25.62osd.3 (host2, 4 TB): 26 PGs, target 25.63osd.4 (host2, 4 TB): 35 PGs, target 25.64osd.5 (host2, 4 TB): 26 PGs, target 25.65osd.6 (host3, 4 TB): 31 PGs, target 25.66osd.7 (host3, 4 TB): 30 PGs, target 25.67osd.8 (host3, 4 TB): 29 PGs, target 25.68osd.9 (host4, 8 TB): 39 PGs, target 51.29osd.10 (host4, 8 TB): 48 PGs, target 51.210osd.11 (host4, 8 TB): 38 PGs, target 51.211host1,host2,host3,host4
Each bar is one OSD and the dashed line its target. Red: overfull, yellow: underfull (relative to upmap_max_deviation).

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 9

Turning 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 eval
targeti = 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_upmap The upmap calculation: overfull and underfull, dropping earlier upmaps, one pair per step
  • src/crush/CrushWrapper.cc :: try_remap_rule, _choose_type_stack, get_rule_weight_osd_map Finding a replacement OSD in the same failure domain
  • src/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 defaults
  • src/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
A fixed snapshot of the simulator; the interactive version is in the web edition's lab. Interactive lab: The balancer: upmap and crush-compat