Linux文件系统选择
通过综合使用多种标准文件系统Benchmarks对Ext3, Ext4, Reiserfs, XFS, JFS, Reiser4的性能测试对比,对不同应用选择合适的文件系统给出以下方案,供大家参考。文件系统性能测试数据见附表。
1、大量小文件(LOSF, Lost of small files)I/O应用(如小图片)
Reiserfs(首选), Ext4文件系统适合这类负载特征,IO调度算法选择deadline,block size = 4096, ext4关闭日志功能。
reiserfs mount参数:-o defaults, async, noatime, nodiratime, notail, data=writeback
ext4 mount参数:-o defaults, async, noatime, nodiratime, data=writeback, barrier=0
关闭ext4日志:tune2fs -O^has_journal /dev/sdXX
2、大文件I/O应用(如视频下载、流媒体)
EXT4文件系统适合此类负载特征,IO调度算法选择anticipatory, block size = 4096, 关闭日志功能,启用extent(default)。
mount参数:-o defaults, async, noatime, nodiratime, data=writeback, barrier=0
关闭ext4日志:tune2fs -O^has_journal /dev/sdXX
3、SSD文件系统选择
EXT4/Reiserfs可以作为SSD文件系统,但未对SSD做优化,不能充分发挥SSD性能,并影响SSD使用时间。
Btrfs对SSD作了优化,mount通过参数启用。但Btrfs仍处于实验阶段,生产环境谨慎使用。
JFFS2/Nilfs2/YAFFS是常用的flash file system,在嵌入式环境广泛应用,建议使用。性能目前还未作测试评估。
简单分析一下选择Reiserfs和ext4文件系统的原因:
1、Reiserfs
大量小文件访问,衡量指标是IOPS,文件系统性能瓶颈在于文件元数据操作、目录操作、数据寻址。reiserfs对小文件作了优化,并使用B+ tree组织数据,加速了数据寻址,大大降低了open/create/delete/close等系统调用开销。mount时指定noatime, nodiratime, notail,减少不必要的inode操作,notail关闭tail package功能,以空间换取更高性能。因此,对于随机的小I/O读写,reiserfs是很好的选择。
2、Ext4
大文件顺序访问,衡量指标是IO吞吐量,文件系统性能瓶颈在于数据块布局(layout)、数据寻址。Ext4对ext3主要作了两方面的优化:
一是inode预分配。这使得inode具有很好的局部性特征,同一目录文件inode尽量放在一起,加速了目录寻址与操作性能。因此在小文件应用方面也具有很好的性能表现。
二是extent/delay/multi的数据块分配策略。这些策略使得大文件的数据块保持连续存储在磁盘上,数据寻址次数大大减少,显著提高I/O吞吐量。
因此,对于顺序大I/O读写,EXT4是很好的选择。另外,XFS性能在大文件方面也相当不错。
附表:文件系统性能测试数据
Testing Host: | ||||||||
CPU | Genuine Intel(R) 2.13GHz 4 cores | |||||||
MEM | 4GB | |||||||
DISK | SAS 146.8GB * 4 | |||||||
/dev/sdb | Ext3 | disable journal | defaults,async,noatime,nodiratime | |||||
/dev/sdc | Ext4 | disable journal | defaults,async,noatime,nodiratime,data=writeback,barrier=0 | |||||
/dev/sdd | XFS | has_journal | defaults,async,noatime,nodiratime,barrier=0 | |||||
/dev/sde | Reiser4 | has_journal | defaults,async,noatime,nodiratime | |||||
/dev/sde | reiserfs | has_journal | defaults,async,noatime,nodiratime,notail,data=writeback | |||||
/dev/sde | JFS | has_journal | defaults,async,noatime,nodiratime | |||||
/dev/sde | btrfs | has_journal | defaults.async.noatime,nodiratime,data=writeback | |||||
NO. | Test Points | Ext3 | Ext4 | Reiserfs | XFS | JFS | Reiser4 | Btrfs |
1 | filesystem creation s | 37.381 | 22.333 | 3.744 | 1.786 | 1.858 | 2.758 | |
2 | filesystem mounting s | 0.024 | 0.039 | 0.299 | 0.079 | 0.068 | 3.524 | |
3 | filesystem unmounting s | 0.011 | 0.02 | 0.074 | 0.025 | 0.048 | 0.037 | |
4 | copy a large file (4GB) s | 35.486 | 37.227 | 30.605 | 43.547 | 30.32 | 42.17 | |
5 | recopy the large file s | 56.919 | 57.526 | 59.893 | 59.315 | 55.654 | 57.925 | |
6 | remove the large file s | 3.126 | 0.295 | 2.178 | 0.016 | 0.018 | 4.137 | |
7 | copy linux kernel archive.tar s | 0.103 | 0.143 | 0.574 | 0.094 | 0.552 | 0.564 | |
8 | extract files from kernel.tar s | 42.678 | 44 | 39.681 | 57.374 | 70.993 | 47.538 | |
9 | create kernel.tar from linux source s | 32.733 | 39.145 | 39.305 | 39.167 | 37.92 | 43.828 | |
10 | compile linux kernel s | 561.834 | 566.474 | 557.429 | 571.355 | 1773.143 | 828.028 | |
11 | copy kernel file tree s | 190.701 | 197.191 | 194.864 | 217.355 | 255.777 | 185.406 | |
12 | recopy kernel file tree s | 66.272 | 170.643 | 100.67 | 143.517 | 194.898 | 79.247 | |
13 | remove kernel file tree s | 13.719 | 3.783 | 3.661 | 50.072 | 92.068 | 33.2 | |
14 | list all files for kernel source(tree) s | 15.961 | 15.539 | 20.717 | 15.818 | 29.139 | 15.611 | |
15 | file search in kernel source (find) s | 0.119 | 0.9 | 0.331 | 2.515 | 0.791 | 5.913 | |
16 | create 1 million files s | 1000.969 | 986.712 | 940.201 | 1128.244 | 1111.509 | 2462.65 | |
17 | recopy the 1 million files s | 4783.069 | 595.828 | 59.252 | 972.671 | 1005.057 | 1734.48 | |
18 | remove the 1 million files s | 3257.384 | 396.32 | 74.917 | 735.048 | 2395.417 | 1165.314 | |
19 | dd read IOPS (bs=1KB,4GB) s | 26.795 | 27.257 | 26.036 | 26.158 | 25.948 | 26.485 | |
20 | dd write IOPS (bs=1KB,4GB) s | 27.006 | 26.461 | 32.577 | 26.164 | 29.203 | 126.906 | |
21 | dd read BW (bs=1MB,4GB) s | 26.784 | 23.552 | 25.999 | 26.233 | 28.635 | 26.541 | |
22 | dd write BW (bs=1MB,4GB) s | 29.429 | 26.123 | 30.64 | 24.683 | 31.446 | 31.925 | |
Postmark (postmark.conf) | ||||||||
23 | transaction /s | 333 | 384 | 384 | 113 | 166 | 416 | |
24 | read MB/s | 27.98 | 20.42 | 24.37 | 9.69 | 10.64 | 30.22 | |
25 | write MB/s | 87.32 | 63.72 | 76.06 | 30.23 | 33.21 | 94.31 | |
Randomio (randomio bigfile 10 .25 .01 2048 60 1) | (X表示Randomio不支持该文件系统) | |||||||
26 | create 4GB file MB/s | 167 | 166 | 164 | 168 | 156 | 51.3 | |
27 | random io/s | 372.1 | 382.3 | 378.8 | 521.5 | 382.7 | X | |
28 | random read latency ms | 26.9 | 26.2 | 26.6 | 13.2 | 26.3 | X | |
29 | random write latency ms | 26.5 | 26 | 25.9 | 37.1 | 25.6 | X | |
30 | random read latency std dev ms | 17.9 | 16.7 | 16.6 | 13.1 | 16.3 | X | |
31 | random write latency std dev ms | 15.8 | 14.9 | 14.5 | 38.8 | 14.3 | X | |
Bonnie++ (-d /cacheX -s 7920 -x 1 -u root) | (+++++表示未获得准确测试结果) | |||||||
32 | read KB/s | 155161 | 150029 | 160919 | 159242 | 155811 | 144079 | |
33 | write KB/s | 155150 | 150635 | 142801 | 159393 | 139770 | 107923 | |
34 | seek /s | 812.9 | 816.7 | 816 | 806.4 | 730.7 | 775.9 | |
35 | sequential create /s | 7374 | (+++++) | 29088 | 710 | 1366 | 10031 | |
36 | sequential delete /s | (+++++) | (+++++) | 25160 | 635 | 470 | 3123 | |
37 | random create /s | 7558 | (+++++) | 28178 | 745 | 509 | 5015 | |
38 | random delete /s | 25292 | (+++++) | 24723 | 559 | 287 | 3365 | |
IOZone (-Razc -s 8192m -y 4k|1m -q 4k|1m -i 0 -i 1 -i 2 -b iozone.xls) | ||||||||
39 | sequential read with 4KB KB/s | |||||||
40 | sequential write with 4KB KB/s | (测试用时太长,暂未完成) | ||||||
41 | random read with 4KB KB/s | |||||||
42 | random write with 4KB KB/s | |||||||
43 | sequential read with 1MB KB/s | 156790 | 153432 | 160142 | 159591 | 161785 | 143197 | |
44 | sequential write with 1MB KB/s | 155928 | 156378 | 131246 | 162226 | 143348 | 138672 | |
45 | random read with 1MB KB/s | 101004 | 98060 | 102840 | 101225 | 101100 | 95864 | |
46 | random write with 1MB KB/s | 110537 | 102245 | 97924 | 107140 | 119733 | 97941 | |
FileBench (load) | ||||||||
47 | randomread | |||||||
48 | randomwrite | |||||||
49 | varmail | |||||||
49 | iops /s | 1292.33 | 1921.658 | 1276.035 | 710.653 | 692.282 | 772.895 | |
BW MB/s | 4.2 | 6.3 | 4.3 | 2.4 | 2.3 | 2.6 | ||
webproxy | ||||||||
50 | iops /s | 14868.189 | 16379.942 | 14984.04 | 6156.159 | 2830.036 | 8705.437 | |
51 | BW MB/s | 55.5 | 60.8 | 56 | 25.1 | 12.3 | 34.7 | |
videoserver | ||||||||
iops /s | 395.147 | 392.849 | 391.85 | 391.65 | 391.74 | 391.048 | ||
BW MB/s | 97.5 | 227.9 | 96.7 | 227.6 | 96.7 |
转载自:http://blog.csdn.net/liuaigui/article/details/5521024/