# SSD wear: how many flash bytes per client byte

*HTML: https://book.ceph-s3.ir/en/lab-ssdwear.html*
*Licence: CC BY-NC-SA 4.0. Author: Ramin Najarbashi.*

[Interactive lab](lab.html)SSD wear: how many flash bytes per client byte
In the book: [Chapter 12](12-bluestore.html#sec-12-6-3), [Chapter 25](25-low-rocksdb.html#sec-25-6)
LabSSD wear: how many flash bytes per client byteGive the write load, IO size, pool type and SSD specs, and see how replication or EC, rounding to min_alloc_size, deferred writes and RocksDB metadata with compaction turn each client byte into several flash bytes, and roughly how many years each OSD lasts.**5.51×**flash bytes per client byte**7938 GB**daily writes per OSD**2.067**DWPD used per OSD**2.4 / 2.2**approximate life (years): average / busiestPer client byteReplicas or chunks**3×Metadata: WAL and flush**0.38×Metadata: compaction**1.88×Recovery and rebalance**0.26×Approximate life of 24 OSDs, from the least to the most busy; the dashed line is the warranty. Red: worn out before the warranty ends.The busiest OSD lasts about 2.2 years, less than the 5-year warranty. A higher-DWPD SSD, more OSDs, larger IO or a better balance (the upmap balancer) helps.per OSD write = io = 16384 B → roundup(·, min_alloc_size) · RocksDB WA ≈ 12 TBW = DWPD × capacity × 365 × years · life = TBW / (TB written per day × 365)`ceph daemon osd.0 perf dump bluefs        # bytes_written_wal, bytes_written_sst
ceph daemon osd.0 perf dump bluestore     # write_big_bytes, write_small_bytes, issued_deferred_write_bytes
smartctl -a /dev/nvme0n1 | grep -i -e "percentage used" -e "data units written"`Small writes cost the most, because the metadata of each write is multiplied by compaction; for pools full of small IO buy high-DWPD SSDs. Read the real numbers from the bluefs counters (chapter 25) and SMART's Percentage Used, and tune the model to them.Follows:`src/os/bluestore/BlueStore.cc :: _do_write_small, _do_write_big (padding to min_alloc_size, deferred below prefer_deferred_size)` Rounding to min_alloc_size and the deferred decision`src/common/options/global.yaml.in :: bluestore_min_alloc_size_ssd (4 KiB), bluestore_prefer_deferred_size_ssd (0), bluestore_rocksdb_options` The SSD defaults and the RocksDB options`src/osd/ECUtil.h :: stripe_info_t; src/common/options/mon.yaml.in :: osd_pool_erasure_code_stripe_unit` EC chunks and the stripe_unit`src/os/bluestore/BlueFS.cc :: bytes_written_wal, bytes_written_sst; BlueStore.cc :: write_big_bytes, write_small_bytes, issued_deferred_write_bytes` The counters that show the real writesA fixed snapshot of the simulator; the interactive version is in the web edition's lab. [Interactive lab: SSD wear: how many flash bytes per client byte](lab-ssdwear.html)The interactive version needs JavaScript; this is a fixed snapshot.
