大网数据广告活动
服务器运维问答

How to obtain read speeds of two disks using mdadm/btrfs raid1 or zfs mirror?

· 52CE 我爱测

Given that RAID1 writes two copies of the data, my understanding is that reads should be close to twice that of a single disk. I have tested read performance of different technologies (mdadm, zfs, btrfs) with little success. From…

问题原文

原帖链接 · Greg · CC BY-SA 3.0

Given that RAID1 writes two copies of the data, my understanding is that reads should be close to twice that of a single disk.

I have tested read performance of different technologies (mdadm, zfs, btrfs) with little success.

From my experience:

  • btrfs only used one disk during reads
  • zfs/mdadm used both disks however the read speed achieved was that of a single disk

I've verified the results using dd, iotop and iostat.

How can data on both disks be read at the same time in order to achieve twice a single disk's read performance?

已采纳解答

原帖链接 · Waxhead · CC BY-SA 3.0

The question is a bit limited on information as to how the test where done so I am assuming that you where just using dd to write directly to a file.

BTRFS:

In BTRFS terms RAID1 means TWO COPIES regardless of how many disks you have in the pool. So for simplicity let's assume that both data and metadata is stored in RAID1 on two disks. Therefore each disk is a copy of the content of the other disk (in BTRFS the disks layout may not be identical).

When BTRFS executes reads it (the last time I checked) relied on the PID of the process to determine what disks to read from first. That means that if you run a single process it will only read from one of the disks, unless there is a error and a good copy needs to be retrieved form the other disk.

The next time you run that process it may have a different PID and BTRFS will read the data from another disk first.

MD: (MDADM)

For reads that are sequential you would not gain much if anything since the same data is on both devices and both disks would therefore need to skip (seek over) the same amount of data before starting a read. E.g. disk A would need to wait (skip over) the first 10 bytes before reading the next 10 bytes and even if disk B could read the first 10 bytes at the same time disk A is skipping it would still need to wait until disk A have finished to be able to put together the 20 bytes it was supposed to read in memory.

From the MD manual page (man md):

"Note that the read balancing done by the driver does not make the RAID1 performance profile be the same as for RAID0; a single stream of sequential input will not be accelerated (e.g. a single dd), but multiple sequential streams or a random workload will use more than one spindle. In theory, having an N-disk RAID1 will allow N sequential threads to read from all disks."

ZFS:

I have no knowledge of ZFS , but I expect it to work roughly the same as BTRFS/MDADM.

CONCLUSION:

For single sequential read operations like you probably do with dd there is not much to be gained performance wise by having a RAID1 setup on both BTRFS and/or MDADM.

If you would like to see the improved read speed (that does exist) on both BTRFS and MDADM you would need to do multiple different reads in parallel on the array. BTRFS would likely distribute reads on different disks based on PID and MDADM should reduce the number of seeks significantly. Remember that RAID1 is not the same as RAID0 and especially not on BTRFS arrays.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-11-12)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。