ITeye博客

对tmpfs的性能测试

blueswind8306 · 2013-08-01 18:59 · Linux · 操作系统 · IO · Markdown

某应用服务器涉及很多临时文件的IO操作,同事建议将文件放在tmpfs上以减少磁盘IO,所以在我的开发机上测试了一下tmpfs和磁盘IO的性能对比,确实差异很大:

测试tmpfs的写性能: 17:06 $ time dd if=/dev/zero of=/dev/shm/test bs=8k count=300000
dd: writing `/dev/shm/test': No space left on device 246069+0 records in 246068+0 records out 2015789056 bytes (2.0 GB) copied, 1.73075 seconds, 1.2 GB/s real 0m1.732s user 0m0.018s sys 0m1.714s

测试tmpfs的读性能: 18:19 $ time dd if=/dev/shm/test of=/dev/null bs=8k 246068+0 records in 246068+0 records out 2015789056 bytes (2.0 GB) copied, 1.28952 seconds, 1.6 GB/s real 0m1.291s user 0m0.018s sys 0m0.820s

测试文件系统的写性能: 17:06 $ time dd if=/dev/zero of=/opt/test bs=8k count=300000
300000+0 records in 300000+0 records out 2457600000 bytes (2.5 GB) copied, 8.574 seconds, 287 MB/s real 0m8.582s user 0m0.053s sys 0m4.070s

测试文件系统的读性能: 18:20 $ time dd if=/opt/test of=/dev/null bs=8k 300000+0 records in 300000+0 records out 2457600000 bytes (2.5 GB) copied, 19.5491 seconds, 126 MB/s real 0m19.550s user 0m0.064s sys 0m1.809s

使用tmpfs存储文件需要注意以下问题:

当服务器重启后,tmpfs内的数据就丢失了 tmpfs会使用内存和swap来存储数据,所以需要注意它对内存和swap的占用情况

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。