Skip to main content
RunBook Academy

CephXXXVIII · RBD PerformanceRBD Performance

Block size and the layers that have one

Advanced⏱ ~17 minrbdfio

What you'll learn

  • Identify the block size at each layer of the stack
  • Align guest filesystem geometry with the RBD layout
  • Diagnose amplification from misalignment
  • Choose block sizes for a given workload

Prerequisites

None — start here.

Verified against Ceph Tentacle 20.2.x · Ceph Squid 19.2.x (supported previous) · cephadm matches the verified Ceph release · podman 4.x · csi-rbd and csi-cephfs current · RBD / CephFS / RGW current (matches Ceph release) · Linux kernel 5.15+ (5.10 minimum) · Ubuntu 24.04 LTS (Ceph host baseline) · Debian 12 (Bookworm) (Ceph host baseline) · Rocky Linux / RHEL / AlmaLinux 9.x (Ceph host baseline) · Proxmox VE 9.x (cross-course integration) · Kubernetes 1.31+ (cross-course integration) · 2026-08-18

Not yet marked complete on this device.

Why this matters in production

Each layer rounds I/O up to its own unit, and the units multiply. A guest write of 512 bytes can become a 4 KiB filesystem block, a 4 KiB BlueStore allocation on each of three OSDs, and — with a snapshot present — a 4 MiB object clone. Knowing where the multiplication happens is how you stop it.

The layers

LayerUnitTypical
Applicationrequest size512 B – 1 MiB
Guest filesystemblock size4 KiB
Guest block devicelogical/physical sector512 B / 4 KiB
RBDobject size4 MiB
BlueStoremin_alloc_size4 KiB

Where amplification occurs

Sub-block application writes. A 512-byte write to a 4 KiB filesystem block means reading the block, modifying it, writing it back — inside the guest, before Ceph sees anything.

Misaligned partitions. A partition starting at an offset that is not a multiple of the filesystem block size makes every block span two underlying blocks:

# check alignment — start sector should be a multiple of 8 for 4 KiB
fdisk -l /dev/rbd0
parted /dev/rbd0 align-check optimal 1

Modern tooling aligns correctly by default; this is a legacy-image concern.

Snapshot copy-on-write. With a snapshot present, the first write to any object clones it, at object granularity.

EC partial-stripe writes. On an EC data pool, a write smaller than the stripe takes the read-modify-write path.

Choosing sizes

# filesystem block size at creation, matching the application
mkfs.xfs -b size=4096 /dev/rbd0
mkfs.ext4 -b 4096 /dev/rbd0

# RBD object size, fixed at creation
rbd create --size 1T --object-size 4M rbd-vms/standard
rbd create --size 10T --object-size 16M rbd-bulk/archive
WorkloadObject size
VM disks, mixed4 MiB (default)
Large sequential archives8–16 MiB, fewer objects and less metadata
Small random with many snapshots1–2 MiB, cheaper copy-on-write

That last row is the non-obvious one: on an image with frequent snapshots, a smaller object size reduces the copy-on-write cost per write, at the price of more objects and more metadata.

Measuring the real distribution

# in the guest
iostat -x 5                     # avgrq-sz, in sectors

# with blktrace for a detailed distribution
btrace /dev/rbd0 | awk '$6=="Q"{print $10}' | sort -n | uniq -c

Design against the measured distribution, not against an assumption about what the application does.

Quiz

Knowledge check · 4 questions

  1. Q1. An image is snapshotted hourly and receives small random writes. Which object size adjustment reduces the copy-on-write cost?

  2. Q2. A 512-byte application write to a 4 KiB filesystem block causes a read-modify-write inside the guest before Ceph is involved.

  3. Q3. Choose an object size for a new archival workload.

    A new RBD volume will hold 40 TB of write-once video files, written sequentially in large blocks and read occasionally. No snapshots are planned. The default 4 MiB object size would create about 10 million objects.

  4. Q4. What does a larger RBD object size cost?

Passing score: 75%. Answers are checked in this browser.

Production discipline

Measure the request-size distribution before choosing an object size, since the parameter is fixed at creation and reasoning about expected behaviour is unreliable. Record the reasoning behind any non-default choice on the image itself, so it survives as a decision rather than looking like an anomaly.

Cross-course references

  • Kubernetes: StorageClass parameters can encode object size per volume class
  • Linux: filesystem block size and partition alignment are the same layered concern