在 Linux 中测试 IO 性能

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1198691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 17:34:24  来源:igfitidea点击:

Testing IO performance in Linux

linuxfile-iostoragebenchmarking

提问by deeplovepan

How do I test IO performance in Linux?

如何在 Linux 中测试 IO 性能?

回答by deeplovepan

tool: fio

工具:fio

link: http://freshmeat.net/projects/fio/

链接:http: //freshmeat.net/projects/fio/

test physical disk IO:

测试物理磁盘IO:

    ./fio examples/disk-zone-profile 

set parameter: sequential r/w: rw=read or rw=write random r/w: rw=randread or rw=randwrite

设置参数:sequential r/w: rw=read or rw=write random r/w: rw=randread or rw=randwrite

回答by dmeister

IO and filesystem benchmark is a complex topic. No single benchmarking tool is good in all situations. Here is a small overview about different benchmarking tools:

IO 和文件系统基准测试是一个复杂的话题。没有一种单一的基准测试工具在所有情况下都是好的。以下是有关不同基准测试工具的简要概述:

Block Storage:

块存储:

  • IOMeter- Highly customizable and allows to coordinate multiple clients. Needs a Windows PC for the coordination application. Developed by Intel. On Linux, take maximum rates of older (at least 2006.07.27 and earlier) with a pinch of salt because the submission method was not optimal.
  • IOMeter- 高度可定制并允许协调多个客户端。需要一台 Windows PC 来运行协调应用程序。由英特尔开发。在 Linux 上,由于提交方法不是最佳的,因此请稍加保留旧版本(至少 2006.07.27 及更早版本)的最大速率。

File System (synthetic):

文件系统(合成):

  • FFSB- Flexible Filesystem Benchmark. Very neat benchmarking for Linux. Good customization of workload. NFS benchmarking (net-ffsb) a bit unsound.
  • Filebench- Extremely powerful, but originally developed for Solaris. Linux support isn't good.
  • sysbench - Mainly a DB benchmarking tool, but also basic filesystem benchmarking tool.
  • bonnie- Seems to be obsolete.
  • bonnie++- C++ port of bonnie. Easy, but seems not to be very customizable.
  • FFSB- 灵活的文件系统基准。非常简洁的 Linux 基准测试。良好的工作量定制。NFS 基准测试 (net-ffsb) 有点不健全。
  • Filebench- 非常强大,但最初是为 Solaris 开发的。Linux 支持不好。
  • sysbench - 主要是一个数据库基准测试工具,也是基本的文件系统基准测试工具。
  • bonnie- 似乎已经过时了。
  • bonnie++- bonnie 的C++ 端口。简单,但似乎不是很可定制。

File System (workload):

文件系统(工作负载):

  • Postmark - Simulates the IO behavior of a mail server. Too small to stress good IO systems.
  • 邮戳 - 模拟邮件服务器的 IO 行为。太小,无法强调良好的 IO 系统。

Stony Brook Universityand IBM Watson Labs have published a highly recommended journal paper in the "Transaction of Storage"about file system benchmarking, in which they present different benchmarks and their strong and weak points: A nine year study of file system and storage benchmarking. The article clearly points out that the results of most benchmarks at least questionable.

石溪大学和 IBM 沃森实验室在“存储交易”中发表了一篇关于文件系统基准测试的强烈推荐期刊论文,其中介绍了不同的基准测试及其优缺点:文件系统和存储基准测试的九年研究。文章明确指出,大多数基准测试的结果至少值得怀疑。



A note:Is the question programming related? Maybe not, but maybe it is. I spend a lot of time benchmarking the IO performance of the systems I develop. At least for me, questions about how to benchmarking these things is highly programming related. Please: Do not close all questions that are not development/programming related from your point of view. The point of view of other developers might be different.

注意:问题与编程有关吗?也许不是,但也许是。我花了很多时间对我开发的系统的 IO 性能进行基准测试。至少对我来说,关于如何对这些东西进行基准测试的问题与编程高度相关。请:不要关闭从您的角度来看与开发/编程无关的所有问题。其他开发人员的观点可能不同。

回答by n-alexander

you need to specify what you're testing for, otherwise benchmarks will only mislead. There are different aspects of IO performance that you need to chose to optimize for, and different parameters to play with.

您需要指定您要测试的内容,否则基准测试只会误导。您需要选择优化 IO 性能的不同方面,以及使用不同的参数。

Your system parameters:

您的系统参数:

  1. storage device: HDD, SSD (which?), Raid (which?)
  2. filesystem, block size, journal mode
  3. file cache, dirty thresholds, amount of memory
  4. IO scheduler, its tunables
  5. number of CPUs
  6. kernel version
  1. 存储设备:HDD、SSD(哪个?)、Raid(哪个?)
  2. 文件系统、块大小、日志模式
  3. 文件缓存、脏阈值、内存量
  4. IO 调度程序,它的可调参数
  5. CPU数量
  6. 内核版本

Your test parameters:

您的测试参数:

  1. read or write performance?
  2. sequential or random?
  3. 1 thread or multiple?
  4. size of requests
  5. optimize for throughput or request delay?
  1. 读或写性能?
  2. 顺序还是随机?
  3. 1个线程还是多个?
  4. 请求的大小
  5. 优化吞吐量或请求延迟?

回答by John

There is an excellent program to test block storage IO on Unix called IORATE. You can get a copy at iorate.org.

有一个优秀的程序可以在 Unix 上测试块存储 IO,称为 IORATE。您可以在 iorate.org 上获得一份副本。

It can generate complex mixed IO, including re-use (hits) and hot zones for tiered storage testing.

它可以生成复杂的混合 IO,包括重用(命中)和用于分层存储测试的热区。

回答by bugaboo

Take a look at IOzone: http://www.iozone.org/

看看 IOzone:http: //www.iozone.org/

If you would like to read a whitepaper illustrating real-world usage on an HPC cluster, please see this pdf, page 36: http://i.dell.com/sites/content/business/solutions/hpcc/en/Documents/Dell-NSS-NFS-Storage-solution-final.pdf

如果您想阅读说明 HPC 集群实际使用情况的白皮书,请参阅此 pdf,第 36 页:http: //i.dell.com/sites/content/business/solutions/hpcc/en/Documents/ Dell-NSS-NFS-Storage-solution-final.pdf

回答by gtsouk

dd if=/dev/sda of=/dev/null

Let this run for a few minutes and stop it with ctrl+C. It will print the read transfer speed of your drive/controller. This is the maximum read speed you can get out of your drive.

让它运行几分钟,然后用 ctrl+C 停止它。它将打印驱动器/控制器的读取传输速度。这是您可以从驱动器中获得的最大读取速度。

回答by bastiat

sysbench

系统工作台

See http://www.howtoforge.com/how-to-benchmark-your-system-cpu-file-io-mysql-with-sysbench

http://www.howtoforge.com/how-to-benchmark-your-system-cpu-file-io-mysql-with-sysbench

Example

例子

sysbench --test=fileio --file-total-size=150G prepare

sysbench --test=fileio --file-total-size=150G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run

It can also test cpu, memory, threads, and database server performance,

它还可以测试cpu、内存、线程和数据库服务器性能,

It's awesome.

这很棒。

Or testing software written in java: http://www.dacapobench.org/

或者用java编写的测试软件:http: //www.dacapobench.org/

回答by arkoak

if you need a quick way without hassle of installing anything . This is the method I use for write speed test:

如果您需要一种无需安装任何东西的快速方法。这是我用于写入速度测试的方法

dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync

And the output is something like this

输出是这样的

root@rackserver:/# dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync
16384+0 records in
16384+0 records out
1073741824 bytes (1.1 GB) copied, 4.86922 s, 221 MB/s

Also :delete the test file after this to recover the extra space used

另外:在此之后删除测试文件以恢复使用的额外空间

Some explanation :

一些解释:

bs = block size
count = the no of blocks to be written

Adjust these parameters to change the size of the file written as per your server specs and the amount of time you want to spend writing.

调整这些参数以更改根据您的服务器规格写入的文件的大小以及您想要花费的时间。

the read speedas suggested already by gtsouk, can be checked by using /dev/null as output.

gtsouk 已经建议的读取速度可以通过使用 /dev/null 作为输出来检查。