The Comprehensive Ceph Guide
فارسیGet started

PG count calculator

In the book: Chapter 7

Lab

PG count calculator

Give the OSD count and each pool's share of the data: see the classic pgcalc answer and what the pg_autoscaler would choose, pass by pass.

4800PG replicas the root may hold
200PG replicas per OSD (proposed)
14.1PG replicas per OSD (current)
Poolsizeclassic pgcalcideal (PG replicas)autoscalerwould it change?
rbd3935 → 102423041024 (even bulk)yes: 32 → 1024
cephfs.data6312 → 2562304256 (even bulk)yes: 32 → 256
cephfs.meta342 → 329632 (non-bulk)no
.mgr38 → 8032 (non-bulk)yes: 1 → 32
pgcalc: pg = pow2( target × OSDs × share / size ), next power up if the nearest is > 25% below
autoscaler: root budget = mon_target_pg_per_osd × OSDs = 200 × 24 = 4800; pool = ⌊capacity_ratio × pg_left⌋ / size, rounded down or up to a power of two by a knapsack over the budget; min pg_num_min (32); changes only past the threshold (3×; 1× at 512/1024, 2× at 2048)

The autoscaler never goes below 32 PGs (osd_pool_default_pg_num) for a pool it manages, and with bulk unset it starts small and grows with the data.

Follows:

  • src/pybind/mgr/pg_autoscaler/module.py :: _get_pool_status, _calculate_final_pool_pg_target the four passes over a root's pools
  • module.py :: PoolGroup, _find_optimal_pg_distribution, _append_result rounding groups of pools within the budget
  • module.py :: nearest_power_of_two, get_dynamic_threshold power of two and the change threshold
  • src/osd/OSDMap.cc :: pool_raw_used_rate raw space per byte (size, or (k+m)/k)
  • src/common/options/mgr.yaml.in :: mon_target_pg_per_osd (200) target PG replicas per OSD
  • src/common/options/global.yaml.in :: mon_max_pg_per_osd (500), osd_pool_default_pg_num (32) the upper limit and the minimum pg_num
A fixed snapshot of the simulator; the interactive version is in the web edition's lab. Interactive lab: PG count calculator