我有一个带有LSI MegaRAID SAS 9260-4i控制器的服务器,带有3 x 2 TB磁盘的RAID-5。 我做了一些性能testing(使用iozone3),数字清楚地表明写caching策略也会影响读取性能。 如果将策略设置为WriteBack,则与WriteThrough相比,我可以获得大约2倍的读取性能。 写入caching如何影响读取性能?
以下是设置的详细信息:
megacli -LDInfo -L0 -a0 Adapter 0 -- Virtual Drive Information: Virtual Drive: 0 (Target Id: 0) Name : RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3 Size : 3.637 TB Is VD emulated : Yes Parity Size : 1.818 TB State : Optimal Strip Size : 512 KB Number Of Drives : 3 Span Depth : 1 Default Cache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU Current Cache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU Default Access Policy: Read/Write Current Access Policy: Read/Write Disk Cache Policy : Disabled Encryption Type : None Bad Blocks Exist: No Is VD Cached: No
随着回写启用(其他一切都没有改变):
Default Cache Policy: WriteBack, ReadAhead, Direct, Write Cache OK if Bad BBU Current Cache Policy: WriteBack, ReadAhead, Direct, Write Cache OK if Bad BBU
一些来自iozone3的数字:
WriteThrough: random random KB reclen write rewrite read reread read write 2033120 64 91963 38146 144980 139122 11795 21564 2033120 128 83039 90746 118660 118147 21193 33686 2033120 256 78933 40359 113611 114327 31493 51838 2033120 512 71133 39453 131113 143323 28712 60946 2033120 1024 91233 76601 141257 142820 35869 45331 2033120 2048 58507 48419 136078 135220 51200 54548 2033120 4096 98426 70490 119342 134319 80883 57843 2033120 8192 70302 63047 132495 144537 101882 57984 2033120 16384 79594 29208 148972 135650 124207 79281 WriteBack: random random KB reclen write rewrite read reread read write 2033120 64 347208 302472 331824 302075 12923 31795 2033120 128 354489 343420 292668 322294 24018 45813 2033120 256 379546 343659 320315 302126 37747 71769 2033120 512 381603 352871 280553 322664 33192 116522 2033120 1024 374790 349123 289219 290284 43154 232669 2033120 2048 364758 342957 297345 320794 73880 264555 2033120 4096 368939 339926 303161 324334 128764 281280 2033120 8192 374004 346851 303138 326100 186427 324315 2033120 16384 379416 340577 284131 289762 254757 356530
有关系统的一些细节:
/dev/sda4 /var ext4 rw,relatime,user_xattr,barrier=1,data=ordered 0 0 通过使用写回caching,您正在节省磁盘IOPS。 控制器可以将较小的写入分批写入一个大的写入。
因此,有更多的IOPS可用于读取。
这假定testing是并发的。 如果给定的testing是只读或只写这不会有问题。
这个testing在哪个文件系统上运行?
想到的是一个时间。 如果你的文件系统是用一个时间选项装载的,或者缺less没有/ relatime装入选项,你会得到一个写每个读。
(atime表示logging文件的上次访问时间)
如果您发布的输出可能会有所帮助
mount
并指定您在哪个设备上进行testing。
当使用像iozone这样的testing时,回写策略会对红色性能产生影响,因为这些基准testing工具通过读取之前写入的数据来衡量读取性能。 因此,当iozone开始读取testing时,一些数据仍然位于caching中,因此读取吞吐量要高得多。 这是不pipe文件的大小,因为RAID适配器不知道文件,甚至文件系统。 所有它知道的是IO和块。 请记住iozonr我会使用一个fs基准工具和暴徒完全抽象硬件。 也许使用-J / -Y你可以减轻回写策略的影响,并了解你的读取性能……或使用真正的硬盘工具(hdparm?)
最明显的原因是因为读取来自caching,而不是磁盘本身。 请记住,在WriteBack中,写入的数据保存在caching中,直到RAID控制器有机会/决定将其写入磁盘。 然而,如果读取相同的数据(或者它仍然保存在caching中的任何数据),那么它使用caching来检索数据,而不是沉迷于相对昂贵的磁盘读取。