Skip to content

TOOLS · CEPH

Ceph PG calculator

Calculate pg_num for every pool with the PGCalc rule or prepare the autoscaler settings, estimate how many PG instances each OSD holds before and after losing a node, and copy the ceph and pveceph commands generated from the same table.

Calculate the PGs of your pools

It starts from the base installation, as in the Ceph calculator: 3 nodes with four NVMe drives and one RBD pool in 3-way replication. The rule gives 512 PGs, because 100 × 12 / 3 is 400 and the nearest power of 2 is 512. Change the inputs or start from an example.

Beta This calculator is in beta. The values and commands are derived from the formulas and assumptions explained on this page: we provide them as is, with no guarantee that they are accurate, complete or suited to your case. Before running the commands on a production cluster, check them against the official documentation or with a systems engineer. To the extent permitted by law, we accept no liability for damages or costs resulting from decisions based on these calculations.

Calculate the PGs of your pools

Start from an editable example:
PG limits and share basis
Pools and calculated PGs
Pool Application and role Protection Class Share of the planned raw capacity in the class (%) Initial PGs, PGCalc estimate PG instances per OSD, this pool Actions
% 512 128.0 instances per OSD

The raw share includes replication or erasure coding: pools with the same logical data can need different raw shares, for example the same data in 3-way replication and EC 4+2 come to 66.67% and 33.33%. target_size_ratio is a relative weight between pools, not a fixed share.

pg_num is a PGCalc estimate of the initial PGs, not the autoscaler algorithm: the autoscaler works with the cluster's mon_target_pg_per_osd (default 100), which the target chosen here does not change. bulk starts a data pool with its full complement of PGs; for metadata and indexes it is usually left off.

Metadata and index pools matter more for object count and omap than for bytes: the share represents them poorly, and the autoscaler handles them with its bias. The commands do not touch .mgr or other existing pools, but their PGs weigh on the same OSDs.

Estimated initial PGs: pool vm-disks: 512. Estimated maximum PG instances per OSD: 128, below mon_max_pg_per_osd 250.

PG instances per OSD, NVMe average 128, estimated maximum 128, limit 250

After losing a node, the remaining nodes are not enough for every instance: 512 cannot be placed. Creation: at the heaviest step the monitor counts 128.0 instances per OSD under rule rep-nvme, within mon_max_pg_per_osd (250). The estimated maximum is within mon_max_pg_per_osd (250); the hard limit of a single OSD is 750.

TOO_MANY_PGS warning: cluster average 128.0 instances per OSD across 12 OSDs, within mon_max_pg_per_osd (250).

Three different checks. On every creation the monitor counts the PGs of the pools on the same CRUSH rule and divides them by the OSDs under its root. The TOO_MANY_PGS warning looks at the average of the whole cluster. The hard limit applies to a single OSD. The maximum is estimated with an ideal distribution: discrete PGs, weights, reweight and object distribution move the real numbers, to be checked with ceph osd df tree, ceph df detail and the PG state.

# Beta calculator: commands provided as is, without warranty. Check them before running them on a production cluster.
# CRUSH rules per device class: create them once
ceph osd crush rule create-replicated rep-nvme default host nvme
ceph osd pool create vm-disks --pg_num 512 --pgp_num 512 --pool_type replicated --rule rep-nvme --size 3 --autoscale_mode warn --bulk
ceph osd pool set vm-disks min_size 2
ceph osd pool application enable vm-disks rbd
# The commands only touch these pools: .mgr and other existing pools stay as they are, but their PGs weigh on the same OSDs. The autoscaler does not scale pools with overlapping CRUSH roots, such as a pool on the default root alongside per-class pools.
# pg_num above is a PGCalc estimate with target 100: it does not set mon_target_pg_per_osd. Value in use in the cluster:
ceph config get mgr mon_target_pg_per_osd
# Check after creation: PGs per pool, usage per OSD and per pool, PG state
ceph osd pool autoscale-status
ceph osd df tree
ceph df detail
ceph pg stat
On this page
  1. How pg_num is calculated
  2. PGCalc or the autoscaler
  3. PG instances per OSD: average and maximum
  4. Ready-made commands
  5. Formulas and sources

Need a second opinion on your pools?

We review the pools, CRUSH rules and PGs of an existing Ceph cluster, or define them as part of a new cluster design.

Ceph PG calculator FAQ

What are Ceph placement groups?

Placement groups, or PGs, are the groups into which Ceph splits the objects of a pool: each PG lives on a set of OSDs, one per copy or chunk, and Ceph moves, recovers and balances data PG by PG. With too few PGs data is spread unevenly, with too many the OSDs use more memory and CPU.

Why is pg_num a power of 2?

Ceph assigns every object of a pool to a PG with a hash: with pg_num a power of 2 each PG gets the same share of objects on average, with another value some PGs get twice as many as others. That is why the PGCalc rule always rounds to a power of 2.

100 or 200 PGs per OSD?

The mon_target_pg_per_osd default is 100; the Squid autoscaler guide recommends 200 for all but the very smallest clusters. The value matters to the autoscaler, which reads it from the cluster: choosing 200 in the calculator changes the estimate of the initial PGs, not the configuration, which you change with ceph config set global mon_target_pg_per_osd. Staying below mon_max_pg_per_osd, 250 by default, matters more than the exact value.

What does the PG autoscaler do, and when should I turn it off?

The Ceph PG autoscaler adjusts the pg_num of every pool based on the data stored, target_size_ratio, target_size_bytes and the cluster's mon_target_pg_per_osd, and with bulk it makes large pools start with their full complement of PGs. Set it to warn (warnings only) or off when you want to decide pg_num yourself, for example to avoid unplanned data movement.

What is mon_max_pg_per_osd?

In Ceph, mon_max_pg_per_osd defaults to 250 in Squid and Tentacle. The monitor uses it when you create a pool or increase pg_num or size: it counts the instances of the pools on the same CRUSH rule, divides them by the OSDs under its root and rejects the command above the limit. The TOO_MANY_PGS warning instead compares the average of the whole cluster across the in OSDs. A single OSD has a hard limit, three times as much with osd_max_pg_per_osd_hard_ratio set to 3. The calculator shows the three checks and also compares the estimated maximum on a single OSD with mon_max_pg_per_osd, before and after losing a node.

How many PGs should an erasure-coded Ceph pool get?

In an erasure-coded Ceph pool every PG has k+m instances, one per chunk: the PGCalc rule therefore divides by k+m instead of by the number of copies. An EC 8+3 pool on 288 OSDs, with 80% of the raw capacity of the class and a target of 100, gets 2,048 PGs.

How does it differ from the PG Calc in the Ceph documentation?

The PG Calc in the Ceph documentation applies the same rule, but only to replicated pools. This calculator adds erasure coding, device classes, an estimate of the instances on every OSD before and after losing a node, and commands for pveceph; the old ceph.com/pgcalc address now returns a 404 error.

  • 700+ active customers
  • 24h support, every day
  • GDPR data kept in Italy

We design your Ceph cluster

We size drives, network, block.db and protection for your workload and, before production, test how the cluster reacts to failures.

Talk to a systems engineer

+39 0421 1885889 · sales@rackone.it

Let's talk about your project

Leave us your details: a systems engineer gets back to you, not a salesperson.

Privacy policy

No spam. If you are already a customer and need support, open a ticket: the link is in the contact details.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Office hours
Monday to Friday, 9:00-18:00 (Italian time) · 24h support for customers

Emergency support, 24h

Cluster down or attack in progress: call now

+39 0421 1880420
Call Talk to an expert