SSDの価格低下に伴い、多くの技術愛好家や企業が、より高いパフォーマンスを求めてCephでSSDベースのストレージプールを構築することを検討し始めています。しかし、Cephで優れたパフォーマンスを確保するためには、適切なSSDの選択が極めて重要です。本記事では、Cephに適したSSDの選び方について探究します。
目次
なぜSSDの選択がこれほど重要なのでしょうか?
現在、消費者は大容量のNVMe SSDを比較的安価に購入できるようになり、多くの技術愛好家やコスト削減を目指す企業主がオールSSDのCephソリューションに投資しています。しかし、価格だけでSSDを選んでしまうと、期待通りのパフォーマンスが得られない可能性があります。
Cephの書き込み特性
Cephについて語る際、書き込み操作がどのように処理されるかを理解する必要があります。Cephのすべての書き込みはトランザクション(transactional)形式で行われます。つまり、各書き込み操作は、すべてのOSDに確実に書き込まれ、fsync()を介してディスクに同期されるまで待機します。これは、Cephがディスク上のキャッシュを使用せず、データが直接NANDに書き込まれることを期待していることも意味します。
このような書き込み動作は、一部のコンシューマー向けSSDにとって大きな課題となります。例えば、80,000 IOPSのパフォーマンスを謳っているSSDでも、実際の使用環境では500〜1000 IOPS程度しか出ないことがあります。
以下のテスト結果からわかるように、Samsung 980 SSDはfsyncを有効にした後のパフォーマンス測定結果がわずか約600 IOPSにとどまっています。
fio -ioengine=libaio -name=test -filename=/dev/nvme0n1 -fsync=1 -direct=1 -bs=4k -iodepth=1 -rw=randwrite -runtime=15
test: (g=0): rw=randwrite, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=1
fio-3.33
Starting 1 process
Jobs: 1 (f=1): [w(1)][100.0%][w=2046KiB/s][w=511 IOPS][eta 00m:00s]
test: (groupid=0, jobs=1): err= 0: pid=3054244: Wed Oct 18 08:03:48 2023
write: IOPS=574, BW=2297KiB/s (2352kB/s)(33.7MiB/15001msec); 0 zone resets
slat (nsec): min=1804, max=27462, avg=4744.29, stdev=1192.14
clat (nsec): min=1082, max=72217, avg=16433.32, stdev=2111.01
lat (nsec): min=12904, max=76816, avg=21177.61, stdev=2867.60
clat percentiles (nsec):
| 1.00th=[13248], 5.00th=[14912], 10.00th=[15040], 20.00th=[15296],
| 30.00th=[15424], 40.00th=[15680], 50.00th=[15808], 60.00th=[16064],
| 70.00th=[16512], 80.00th=[17792], 90.00th=[18560], 95.00th=[19584],
| 99.00th=[22912], 99.50th=[25984], 99.90th=[31616], 99.95th=[43264],
| 99.99th=[72192]
bw ( KiB/s): min= 2040, max= 2440, per=100.00%, avg=2305.38, stdev=85.23, samples=29
iops : min= 510, max= 610, avg=576.34, stdev=21.31, samples=29
lat (usec) : 2=0.01%, 20=96.45%, 50=3.51%, 100=0.03%
fsync/fdatasync/sync_file_range:
sync (usec): min=1108, max=6437, avg=1735.07, stdev=240.93
sync percentiles (usec):
| 1.00th=[ 1188], 5.00th=[ 1565], 10.00th=[ 1582], 20.00th=[ 1631],
| 30.00th=[ 1663], 40.00th=[ 1680], 50.00th=[ 1696], 60.00th=[ 1713],
| 70.00th=[ 1778], 80.00th=[ 1827], 90.00th=[ 1893], 95.00th=[ 2024],
| 99.00th=[ 2638], 99.50th=[ 2966], 99.90th=[ 4047], 99.95th=[ 5473],
| 99.99th=[ 6456]
cpu : usr=0.29%, sys=0.89%, ctx=25839, majf=0, minf=12
IO depths : 1=200.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued rwts: total=0,8615,0,8615 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=1
Run status group 0 (all jobs):
WRITE: bw=2297KiB/s (2352kB/s), 2297KiB/s-2297KiB/s (2352kB/s-2352kB/s), io=33.7MiB (35.3MB), run=15001-15001msec
Disk stats (read/write):
nvme0n1: ios=46/17115, merge=0/0, ticks=10/14751, in_queue=29383, util=99.46%
停電保護:無視できない重要な機能
SSDの停電保護機能は、突然の停電時でもすべての書き込み操作が正しく完了することを保証します。これにより、SSDのキャッシュが非揮発性ストレージのように機能するため、SSDコントローラーはfsync()を安全に無視でき、データが正しく書き込まれるという確信を持つことができます。
SSDの停電保護は、予期せぬ停電が発生した際に、ディスク上のキャッシュにあるデータを引き続きNANDに書き込めるようにする機能です。SSDにこの機能が備わっていると、SSDのキャッシュが非揮発性(non-volatile)ストレージのように動作し、コントローラーはfsyncを安全に無視できるようになります。突然の停電後でもデータが正常に書き込まれると信頼できるからです。
停電保護機能を持つSSD(Kioxia CD6)のテスト結果を上記のSamsung 980と比較すると、平均で36.6k IOPS出ていることがわかります。
fio -ioengine=libaio -name=test -filename=/dev/nvme2n1 -fsync=1 -direct=1 -bs=4k -iodepth=1 -rw=randwrite -runtime=15
test: (g=0): rw=randwrite, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=1
fio-3.33
Starting 1 process
Jobs: 1 (f=1): [w(1)][100.0%][w=144MiB/s][w=36.9k IOPS][eta 00m:00s]
test: (groupid=0, jobs=1): err= 0: pid=3720075: Wed Oct 18 17:04:25 2023
write: IOPS=36.6k, BW=143MiB/s (150MB/s)(2144MiB/15001msec); 0 zone resets
slat (usec): min=3, max=1828, avg= 5.84, stdev= 3.94
clat (nsec): min=880, max=1772.2k, avg=17675.95, stdev=5502.60
lat (usec): min=14, max=1867, avg=23.52, stdev= 6.86
clat percentiles (usec):
| 1.00th=[ 16], 5.00th=[ 17], 10.00th=[ 18], 20.00th=[ 18],
| 30.00th=[ 18], 40.00th=[ 18], 50.00th=[ 18], 60.00th=[ 18],
| 70.00th=[ 18], 80.00th=[ 19], 90.00th=[ 19], 95.00th=[ 20],
| 99.00th=[ 24], 99.50th=[ 28], 99.90th=[ 50], 99.95th=[ 69],
| 99.99th=[ 151]
bw ( KiB/s): min=134970, max=167288, per=100.00%, avg=146491.97, stdev=6017.07, samples=29
iops : min=33742, max=41822, avg=36622.90, stdev=1504.33, samples=29
lat (nsec) : 1000=0.01%
lat (usec) : 2=0.02%, 4=0.01%, 10=0.01%, 20=96.92%, 50=2.95%
lat (usec) : 100=0.08%, 250=0.01%, 500=0.01%, 750=0.01%, 1000=0.01%
lat (msec) : 2=0.01%
fsync/fdatasync/sync_file_range:
sync (usec): min=2, max=1790, avg=20.43, stdev= 5.76
sync percentiles (usec):
| 1.00th=[ 17], 5.00th=[ 20], 10.00th=[ 20], 20.00th=[ 20],
| 30.00th=[ 20], 40.00th=[ 20], 50.00th=[ 21], 60.00th=[ 21],
| 70.00th=[ 21], 80.00th=[ 22], 90.00th=[ 22], 95.00th=[ 22],
| 99.00th=[ 28], 99.50th=[ 32], 99.90th=[ 55], 99.95th=[ 74],
| 99.99th=[ 159]
cpu : usr=19.77%, sys=40.01%, ctx=549142, majf=0, minf=24
IO depths : 1=200.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued rwts: total=0,548737,0,548736 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=1
Run status group 0 (all jobs):
WRITE: bw=143MiB/s (150MB/s), 143MiB/s-143MiB/s (150MB/s-150MB/s), io=2144MiB (2248MB), run=15001-15001msec
Disk stats (read/write):
nvme2n1: ios=0/542994, merge=0/0, ticks=0/7889, in_queue=7890, util=99.36%
SATA接続のIntel DC S3500 SSDでさえ、Samsung 980よりもはるかに優れたパフォーマンスを示しています。
fio -ioengine=libaio -name=test -filename=/dev/sda -fsync=1 -direct=1 -bs=4k -iodepth=1 -rw=randwrite -runtime=15
test: (g=0): rw=randwrite, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=1
fio-3.33
Starting 1 process
Jobs: 1 (f=1): [w(1)][100.0%][w=34.0MiB/s][w=8712 IOPS][eta 00m:00s]
test: (groupid=0, jobs=1): err= 0: pid=3172: Thu Oct 19 04:58:04 2023
write: IOPS=8713, BW=34.0MiB/s (35.7MB/s)(511MiB/15001msec); 0 zone resets
slat (nsec): min=5381, max=60223, avg=5695.98, stdev=404.63
clat (usec): min=35, max=289, avg=49.89, stdev=15.41
lat (usec): min=44, max=295, avg=55.59, stdev=15.42
clat percentiles (usec):
| 1.00th=[ 41], 5.00th=[ 41], 10.00th=[ 42], 20.00th=[ 42],
| 30.00th=[ 43], 40.00th=[ 43], 50.00th=[ 44], 60.00th=[ 47],
| 70.00th=[ 49], 80.00th=[ 53], 90.00th=[ 69], 95.00th=[ 82],
| 99.00th=[ 113], 99.50th=[ 127], 99.90th=[ 182], 99.95th=[ 206],
| 99.99th=[ 265]
bw ( KiB/s): min=34672, max=34992, per=100.00%, avg=34877.79, stdev=57.17, samples=29
iops : min= 8668, max= 8748, avg=8719.45, stdev=14.29, samples=29
lat (usec) : 50=74.10%, 100=24.24%, 250=1.64%, 500=0.03%
fsync/fdatasync/sync_file_range:
sync (usec): min=81, max=432, avg=108.51, stdev=32.18
sync percentiles (usec):
| 1.00th=[ 87], 5.00th=[ 88], 10.00th=[ 89], 20.00th=[ 90],
| 30.00th=[ 91], 40.00th=[ 92], 50.00th=[ 96], 60.00th=[ 100],
| 70.00th=[ 110], 80.00th=[ 124], 90.00th=[ 149], 95.00th=[ 163],
| 99.00th=[ 265], 99.50th=[ 297], 99.90th=[ 355], 99.95th=[ 367],
| 99.99th=[ 392]
cpu : usr=1.86%, sys=14.13%, ctx=392131, majf=0, minf=12
IO depths : 1=200.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued rwts: total=0,130710,0,130709 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=1
Run status group 0 (all jobs):
WRITE: bw=34.0MiB/s (35.7MB/s), 34.0MiB/s-34.0MiB/s (35.7MB/s-35.7MB/s), io=511MiB (535MB), run=15001-15001msec
Disk stats (read/write):
sda: ios=0/258623, merge=0/0, ticks=0/13669, in_queue=20496, util=99.21%
SSDのパフォーマンスを測定する方法は?
SSDが本当にCephでの使用に適しているかを確認する良い方法は、パフォーマンステストを行うことです。以下に推奨されるテストコマンドを示します。
fio -ioengine=libaio -name=test -filename=/dev/nvme2n1 -fsync=1 -direct=1 -bs=4k -iodepth=1 -rw=randwrite -runtime=15
その中の -fsync=1 これにより、各書き込みがSSDに同期されることが保証されます。これはCephの実際の動作方式を反映したものです。
結論:SSD選びの最適な戦略
以上の議論に基づき、Cephに適したSSDを選択する際は、以下の2つの基本原則に従うことができます。
- エンタープライズ向け NVMe > エンタープライズ向け SATA/SAS >>>>>> コンシューマー向け NVMe/SATA/SAS。
- SSDは停電保護機能を備えている必要があります。
これらの原則に基づいて選択するだけで、Ceph環境で最高のパフォーマンスを確実に得ることができます。
付録
テスト環境
Samsung 980 1TB
- CPU:AMD EPYC 7413
- メモリ:8 x 32GB DDR4 3200 RDIMM
- kernel: 6.1.0-9-amd64
Kioxia CD6 3.84TB
- CPU:2 x Ampere Altra Q80-30
- メモリ: 4 x 32GB DDR4 3200 RDIMM
- kernel: 6.1.0-12-arm64
インテル DC S3500 1.6TB
- CPU: AMD Epyc 7302P
- メモリ: 4 x 32GB DDR4 2933 RDIMM
- カーネル: 6.2.16-15-pve
参考文献
著作権表示:特に断りのない限り、本ブログのすべての記事はCC BY-NC-SA 4.0ライセンスの下で提供されています。

