09. Ceph in Practice: RADOS, CRUSH Algorithm, BlueStore & Cluster Operations
Prerequisites: Module 01 (Storage Metrics), Module 06 (Block Storage & LVM), Module 08 (Distributed Storage & Quorums).
Target Audience: Infrastructure Architects, Kubernetes Platform Engineers, Storage Administrators, and Cloud SREs.
Ceph is the open-source industry standard for software-defined distributed storage. It unifies block devices (RBD), POSIX file systems (CephFS), and S3-compatible object storage (RGW) on top of a single autonomous, self-healing, peer-to-peer storage engine called RADOS (Reliable Autonomic Distributed Object Store).
Unlike traditional distributed storage systems that bottleneck on central metadata lookup tables, Ceph computes the physical location of any object deterministically using the CRUSH algorithm.
1. Ceph Unified Architecture & The Daemon Ecosystemβ
+-----------------------------------------------------------------------------------+
| Ceph Access Interfaces (Client Application Layer) |
| [ RBD: RADOS Block Device ] [ CephFS: POSIX File System ] [ RGW: S3 / Swift ]|
| (Kubernetes CSI / QEMU-KVM) (Shared Multi-Client Mount) (HTTP REST Object) |
+-----------------------------------------|-----------------------------------------+
βΌ
+-----------------------------------------------------------------------------------+
| librados: Native C/C++, Python, Go, Java, Rust Object API Client Library |
+-----------------------------------------|-----------------------------------------+
βΌ
+-----------------------------------------------------------------------------------+
| RADOS (Reliable Autonomic Distributed Object Store) Layer |
| Peer-to-peer, self-healing, CRUSH-routed storage cluster |
+-----------------------------------------------------------------------------------+
β² β² β²
β β β
ββββββ΄βββββββββββββββββββββββββ ββββ΄βββββββββββββββββββββββββ ββββ΄βββββββββββββββββββ
β Ceph MON (Monitor) β β Ceph MGR (Manager) β β Ceph OSD (Object β
β - Cluster state authority β β - Telemetry & metrics β β Storage Daemon) β
β - Paxos quorum (3 or 5) β β - Prometheus / Grafana β β - Manages 1 drive β
β - Maintains master maps: β β - Orchestrates rebalance β β - BlueStore Engine β
β monmap, osdmap, pgmap β β - Ceph Dashboard Web UI β β - Peering & Healing β
βββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ βββββββββββββββββββββββ
The Ceph Daemon Rolesβ
- OSD (Object Storage Daemon): Manages one physical storage drive (NVMe SSD or HDD). Hundreds to thousands of OSDs run across cluster nodes. OSDs peer directly with one another to replicate data, handle heartbeats, perform scrubbing, and rebalance data without central coordinator bottlenecks.
- MON (Monitor): Maintains the definitive master maps of cluster state (
monmap,osdmap,pgmap,crushmap) using Paxos consensus. Mon daemons require an odd quorum (typically 3 or 5 nodes) and reside strictly on the control plane. - MGR (Manager): Runs alongside MONs to offload read-heavy monitoring, telemetry collection, Prometheus metric exporters, and cluster orchestration modules.
- MDS (Metadata Server): Required only for CephFS. Manages the POSIX filesystem hierarchy, directory dentries, and inode locks in DRAM, storing the underlying file extents as raw RADOS objects.
2. The CRUSH Algorithm: Eliminating Central Metadata Lookupsβ
At petabyte-to-exabyte scales, centralized metadata lookup servers (such as HDFS NameNodes or traditional SAN metadata controllers) suffer catastrophic scalability limits, memory exhaustion, and single points of failure.
Ceph eliminates metadata lookup tables entirely through CRUSH (Controlled Replication Under Scalable Hashing):
Client has Object: "production-backup-2026.iso" in Pool "backup-pool"
β
βΌ
Step 1: Hash Object Name into 32-bit Integer via Jenkins Hash
Hash("production-backup-2026.iso") = 0x8F3A41D2
β
βΌ
Step 2: Map Hash to Placement Group (PG)
PG ID = 0x8F3A41D2 % 128 (Total PGs in Pool) = "backup-pool.82"
β
βΌ
Step 3: Evaluate CRUSH Algorithm over Cluster Map
CRUSH(ClusterMap, Rule: "replicate across 3 racks", PG: "backup-pool.82")
β
βΌ
Result: Deterministic Target OSD Triad: [ OSD 14 (Rack A), OSD 42 (Rack B), OSD 89 (Rack C) ]
Client connects directly to OSD 14 to write! Zero metadata server queries!
CRUSH Failure Domain Isolationβ
CRUSH organizes the cluster map into an administrative tree of hierarchical buckets:
Root Datacenter Room Rack Host OSD.
- When configured with
step chooseleaf firstn 3 type rack, CRUSH guarantees that the 3 replicas of an object are assigned to 3 completely independent physical racks with distinct power distribution units (PDUs) and network switches.
3. Placement Groups (PGs) & The BlueStore Storage Engineβ
What is a Placement Group (PG)?β
A Placement Group is a logical aggregation layer between millions of individual objects and hundreds of physical OSDs:
- Tracking replication states per individual object would consume gigabytes of cluster map memory.
- Ceph maps millions of objects into a fixed number of Placement Groups (PGs) (typically thousands).
- PGs are mapped deterministically to sets of OSDs via CRUSH.
BlueStore: The Modern OSD Engineβ
In early Ceph releases, OSDs used FileStore, which stored objects as individual files on top of a standard Linux filesystem (XFS). This caused severe double-journaling write amplification and slow directory traversals.
Modern Ceph uses BlueStore, which writes directly to raw block devices:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Ceph OSD Daemon (BlueStore Architecture) β
βββββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ€
β RocksDB Metadata Key-Value Store β BlueFS (Minimal Micro-Filesystem) β
β - Stores object metadata, extent maps,β - Bridges raw block storage for β
β omap key-values, and checksums β RocksDB SST files and WAL logs β
βββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββ€
β BlueStore Block Allocator (StupidAllocator / Bitmap Allocator) β
β - Allocates physical blocks directly on raw disk (bypassing Linux VFS) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Physical Storage Media β
β ββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββ β
β β DB/WAL NVMe SSD Partition β β Main Data HDD / SSD Partition β β
β β (RocksDB WAL + BlueFS blocks)β β (Raw user data payload extents) β β
β ββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Key BlueStore Capabilities:β
- Zero Double-Journaling: Data is written directly to raw blocks. Small writes are merged into RocksDB WAL, while large writes are committed directly to disk using Copy-on-Write semantics.
- Cryptographic Checksumming: Every block is verified on read using crc32c or xxhash to detect and heal silent bit-rot.
- Inline Compression: Automatically compresses cold data using Snappy, LZ4, or Zstandard algorithms.
4. Governing Mathematical Formulationsβ
1. Optimal Placement Group (PG) Calculation Formulaβ
Undersized PG counts cause severe data imbalance across OSDs; oversized PG counts consume excessive OSD CPU and DRAM memory:
Round the result up to the nearest power of 2 to ensure uniform hashing distribution.
- Example: A 48-OSD cluster configured with 3x replication:
2. Ceph Usable Capacity & Safety Thresholdsβ
Ceph enforces strict cluster-wide storage safety thresholds:
mon_osd_nearfull_ratio(Default / 85%): Cluster raises warnings.mon_osd_backfillfull_ratio(Default / 90%): Cluster halts automatic rebalancing to prevent overflowing surviving disks.mon_osd_full_ratio(Default / 95%): Cluster immediately freezes all client I/O operations.
5. Hands-on Linux Lab: Ceph Operations & CLI Commandsβ
Step 1: Inspect Cluster Health & Tree Topologyβ
# Display high-level cluster health, active monitors, PGs, and I/O rates
sudo ceph status
# Display hierarchical CRUSH tree of hosts, racks, and OSD states
sudo ceph osd tree
# Check pool capacity usage and raw vs usable statistics
sudo ceph df
Step 2: Create a High-Performance RBD Block Poolβ
# 1. Create a pool named 'k8s_volumes' with 128 PGs
sudo ceph osd pool create k8s_volumes 128 128 replicated
# 2. Enable RBD application tagging
sudo ceph osd pool application enable k8s_volumes rbd
# 3. Create a 50 GB thinly provisioned block volume
rbd create --size 50G --pool k8s_volumes vol_mysql_data
# 4. Map the volume to the host kernel block layer
sudo rbd map k8s_volumes/vol_mysql_data
# Output: /dev/rbd0
# 5. Format and mount
sudo mkfs.xfs /dev/rbd0
sudo mount /dev/rbd0 /mnt/mysql
Step 3: Simulate OSD Failure & Observe Self-Healingβ
# Mark OSD 3 as 'out' (simulating hardware drive failure)
sudo ceph osd out osd.3
# Watch Ceph PGs automatically transition through:
# active+undersized+degraded -> active+recovering -> active+clean
watch -n 1 "ceph pg stat && ceph status"
6. Real-World Production Failure Scenariosβ
Failure Scenario 1: The OSD Nearfull Death Cascadeβ
Incidentβ
A 200-node Ceph cluster was running at 82% capacity. A disk failure triggered automatic backfilling:
- Surviving disks absorbed data from the failed drive.
- Two adjacent disks crossed the
nearfull(85%) threshold and hitfull(95%). - Ceph immediately marked those full OSDs as down/out.
- The data from those newly disabled OSDs was redistributed onto the remaining drives, pushing more disks past 95%.
- Within 20 minutes, a cascading freeze locked the entire cluster, halting thousands of enterprise VMs.
Remediation & Recoveryβ
- Never operate Ceph above 75% capacity without expanding storage nodes.
- If trapped in a full-ratio lockup, temporarily raise the safety thresholds to unblock I/O while purging old snapshots:
sudo ceph osd set-full-ratio 0.97sudo ceph osd set-backfillfull-ratio 0.94
- Purge orphaned RBD snapshots and unused pools.
Failure Scenario 2: Slow/Flapping OSD Causing Global Tail Latency Spikesβ
Incidentβ
Kubernetes application database queries experienced random 15-second latency spikes.
Monitoring showed overall cluster IOPS and CPU were low, but ceph -s reported slow requests are blocked > 32 sec.
Root Causeβ
A single mechanical HDD was experiencing silent SATA read retries and physical head degradation:
- The disk didn't fail outright; it responded to heartbeats, but writes took .
- Because CRUSH stripes PGs evenly across OSDs, every client writing to a placement group that included this slow OSD was blocked.
Solution: Automated Flapping Isolationβ
# Pinpoint the slow OSD using Ceph daemon perf counters
sudo ceph osd perf | sort -k 2 -n -r | head -n 5
# Immediately take the slow drive out of service
sudo ceph osd out <OSD_ID>
sudo systemctl stop ceph-osd@<OSD_ID>
7. Practical Engineering Exercises (With Solutions)β
Exercise: Ceph Capacity Planning with Nearfull Reservesβ
Problem: An enterprise requires of usable storage for virtual machine disks (RBD) using 3x replication. The cluster uses standard enterprise NVMe SSDs.
- What total raw storage capacity is required?
- How many physical drives must be provisioned to ensure the cluster never crosses the safe operational threshold?
Solution:β
- Calculate raw storage requirement:
- Calculate total provisioned capacity with an 80% ceiling:
- Sizing physical drives:
- Engineering Conclusion: Delivering 150 TB of resilient usable storage requires at least 36 physical 16 TB SSDs ( raw) to ensure high availability and prevent catastrophic nearfull rebalancing cascades during drive failures.
8. Summary Checklist & Key Takeawaysβ
- CRUSH Computes, Doesn't Lookup: Ceph clients calculate object locations mathematically using the CRUSH algorithm, eliminating centralized metadata server bottlenecks.
- BlueStore Bypasses the OS Filesystem: Writes directly to raw block devices, eliminating double journaling and bit rot via end-to-end checksums.
- Sizing PGs Correctly is Crucial: Aim for ~100 PGs per OSD per pool, rounded up to the nearest power of 2.
- Never Exceed 80% Capacity: Rebalancing after a drive failure will consume additional space and risk cascading nearfull freezes.
- Slow OSDs are More Dangerous Than Dead OSDs: A dead OSD fails fast; a slow flapping OSD stalls client I/O across the entire cluster.