常见磁盘性能测试

常见磁盘性能测试

准备

为提高性能值,进入BIOS设置如下两项。

1、Power Policy设置成performance
2、关超线程(Advanced—>Hyper-Threading)

1. 测试工具

  1. 磁盘性能测试工具fio
  2. nmon文件解析工具nmon
  3. nmon文件解析工具(Nmon-Analyser)

2. 测试要求

  1. 如果有Raid卡,可以通过管理工具把硬盘设置为单盘直通模式,每个规格只需测试其中一个盘即可(有时性能不达标,可以换个盘测下,毕竟盘也是有优良率的)。
  2. 编写测试脚本,确定好最优参数(参考5.测试脚本),修改其中的盘符为正确的盘符(否则可能导致写没系统)。
  3. 确定Fio工具版本,一般使用新版本会稳定些,此次测试使用的是3.20版本。
  4. 无其他业务运行。

3. 开始测试

根据测试需求编辑好第5章节的测试脚本,主要检查:

  1. 测试盘:filename参数。

    例如测试环境如下, 那么sata盘的filename就是/dev/sdb;nvme盘就是nvme0n1或者nvme1n1 。

    注意:如果有拔盘插盘操作(安装新的SCSI设备后,可能出现盘符漂移情况),需要再次查看磁盘盘符,并修改脚本,linux系统盘符漂移原理说明

[root@localhost shell]# lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0 447.1G  0 disk
sdb               8:16   0 447.1G  0 disk
sdc               8:32   0 446.1G  0 disk
├─sdc1            8:33   0   200M  0 part /boot/efi
├─sdc2            8:34   0   976M  0 part /boot
└─sdc3            8:35   0   445G  0 part
  ├─centos-root 253:0    0 405.9G  0 lvm  /
  └─centos-swap 253:1    0  39.1G  0 lvm  [SWAP]
nvme0n1         259:1    0   1.8T  0 disk
nvme1n1         259:0    0   1.8T  0 disk

执行以下脚本开始测试即可,sata盘和nvme盘每一个指标执行时间和脚本中的 runtime参数一致。

#!/bin/bash
bash sata.sh
#sleep 100
bash nvme.sh

4. 结果分析

跑完后,会在对应文件夹生成类似如下日志:

NVMe:

init_seq2.log
localhost_210422_0323.nmon
localhost_210422_0426.nmon
localhost_210422_0529.nmon
localhost_210422_0632.nmon
localhost_210422_1504.nmon
nvme0n14K_randR_1_1.log_clat.log
nvme0n14K_randR_1_1.log_lat.log
nvme0n14K_randR_1_1.log_slat.log
nvme0n14K_randR_latency.log
nvme0n14K_randW_latency.log

sata:

128K_seqR_iops.log_iops.log
128K_seqR_lat.log_clat.log
128K_seqR_lat.log_lat.log
128K_seqR_lat.log_slat.log
128K_seqR.log
128K_seqW_iops.log_iops.log
128K_seqW_lat.log_clat.log
128K_seqW_lat.log_lat.log
128K_seqW_lat.log_slat.log
128K_seqW.log
4K_randR_iops.log_iops.log
4K_randR_lat.log_clat.log
4K_randR_lat.log_lat.log
4K_randR_lat.log_slat.log
4K_randR.log
4K_randW_iops.log_iops.log
4K_randW_lat.log_clat.log
4K_randW_lat.log_lat.log
4K_randW_lat.log_slat.log
4K_randW.log
init_seq2.log
localhost_210421_1202.nmon
localhost_210421_1303.nmon
localhost_210421_1518.nmon
localhost_210421_1619.nmon

其中.nmon文件就是我们要分析的,生成时间对应我们脚本的中的执行顺序。

分别分析完生成的文件列表类似:

atlas_200331_0157.nmon
atlas_200331_0157.nmon.xlsx
atlas_200331_0258.nmon
atlas_200331_0258.nmon.xlsx
atlas_200331_0517.nmon
atlas_200331_0517.nmon.xlsx
atlas_200331_0618.nmon
atlas_200331_0618.nmon.xlsx
nmon analyser v34a.xls

开始分析:

  • 性能-随机读 (稳态iops均值)

使用Nmon-Analyser打开对应文件,找到”DISKXFER“sheet,计算均值;
随机读写注意观察结果的稳定性,要求在均值的0.9~1.1倍范围内的个数的比例要大于93%(随机读)或者85%(随机写)

AVERAGE(B3:B1802)
AVERAGE(B3:B1802)*0.9
AVERAGE(B3:B1802)*1.1
COUNTIFS(B3:B1802,">"&B1992,B3:B1802,"<"&B1993)/1800
  • 性能-随机写 (稳态iops均值)

使用Nmon-Analyser打开对应文件,找到”DISKXFER“sheet,计算均值;
随机读写注意观察结果的稳定性,要求在均值的0.9~1.1倍范围内的个数的比例要大于93%(随机读)或者85%(随机写)

AVERAGE(B3:B1802)
AVERAGE(B3:B1802)*0.9
AVERAGE(B3:B1802)*1.1
COUNTIFS(B3:B1802,">"&B1992,B3:B1802,"<"&B1993)/1800
  • 性能-顺序读带宽(MB,1MB=1024KB)

使用Nmon-Analyser打开对应文件,找到”DISKREAD“sheet,计算均值;

AVERAGE(B2:B1802)。

  • 性能-顺序写带宽(MB,1MB=1024KB)

使用Nmon-Analyser打开对应文件,找到”DISKWRITE“sheet,计算均值;

AVERAGE(B2:B1802)。

  • 性能-随机读时延(ms,1s=1000ms)

此指标只针对NVMe盘,查看nvme0n14K_randR_latency.logclat (usec): min=0, max=3534, avg=72.93, stdev=20.51,其中avg即为实测值。

[root@localhost nvmetestfile]# cat nvme0n14K_randR_latency.log
mytest: (g=0): rw=randread, bs=4K-4K/4K-4K/4K-4K, ioengine=libaio, iodepth=1
fio-2.1.10
Starting 1 thread

mytest: (groupid=0, jobs=1): err= 0: pid=1245: Thu Apr 22 06:32:07 2021
  read : io=187014MB, bw=53195KB/s, iops=13298, runt=3600001msec
    slat (usec): min=1, max=163, avg= 1.62, stdev= 0.56
    clat (usec): min=0, max=3534, avg=72.93, stdev=20.51
     lat (usec): min=47, max=3535, avg=74.62, stdev=20.51
    clat percentiles (usec):

...
  • 性能-随机写时延(ms,1s=1000ms)

    此指标只针对NVMe盘,查看nvme0n14K_randW_latency.logclat (usec): min=0, max=3534, avg=72.93, stdev=20.51,其中avg即为实测值。

1. SATA

SATA 盘一般会测试4个指标:

机型达标满分投标“硬盘型号”第1次测试结果“硬盘型号”第2次测试结果备注
SATA SSD盘性能-读(稳态iops均值)
SATA SSD盘性能-写(稳态iops均值)
SATA SSD盘性能-读带宽(MB,1MB=1024KB)
SATA SSD盘性能-写带宽(MB,1MB=1024KB)
硬盘得分

2. NVMe

NVMe 盘一般会测试6个指标:

机型达标满分投标“硬盘型号”第1次测试结果“硬盘型号”第2次测试结果备注
PCI-E SSD性能-随机读 (稳态iops均值)
PCI-E SSD性能-随机写 (稳态iops均值)
PCI-E SSD性能-顺序读带宽(MB,1MB=1024KB)
PCI-E SSD性能-顺序写带宽(MB,1MB=1024KB)
PCI-E SSD性能-随机读时延(ms,1s=1000ms)
PCI-E SSD性能-随机写时延(ms,1s=1000ms)
硬盘得分

5. 测试脚本

常见测试值:

satasataNVMeNVMe
numjobsiodepthnumjobsiodepth
随机读1128864
随机写832864
顺序读11281256
顺序写11281256

sata

# cat sata.sh

#!/bin/bash

filename=/dev/sda # 待测磁盘,需要根据实际环境修改!
outdir=/home/work/satatestfile # 测试数据输出路径!
pre_runtime=7200
runtime=3600

#Script of precondition:4K IOPS
fio --ioengine=libaio --direct=1 --thread --norandommap --filename=$filename --name=$outdir/init_seq --output=$outdir/init_seq.log --rw=write --bs=128k --numjobs=1 --iodepth=32 --loops=3
fio --ioengine=libaio --direct=1 --thread --norandommap --filename=$filename --name=$outdir/init_rand --output=$outdir/init_rand.log --rw=randwrite --bs=4k --numjobs=1 --iodepth=32 --ramp_time=60 --runtime=$pre_runtime

#4k Random Read
nohup ./nmon -f -s 2 -c 1900 -m $outdir &
fio --ioengine=libaio --randrepeat=0 --norandommap --thread --direct=1 --group_reporting --name=mytest --ramp_time=60 --runtime=$runtime --time_based --numjobs=1 --iodepth=128 --filename=$filename --rw=randread --bs=4k --output=$outdir/4K_randR.log --log_avg_msec=1000 --write_iops_log=$outdir/4K_randR_iops.log --write_lat_log=$outdir/4K_randR_lat.log
#4k Random Write
nohup ./nmon -f -s 2 -c 1900 -m $outdir &
fio --ioengine=libaio --randrepeat=0 --norandommap --thread --direct=1 --group_reporting --name=mytest --ramp_time=60 --runtime=$runtime --time_based --numjobs=8 --iodepth=32 --filename=$filename --rw=randwrite --bs=4k --output=$outdir/4K_randW.log --log_avg_msec=1000 --write_iops_log=$outdir/4K_randW_iops.log --write_lat_log=$outdir/4K_randW_lat.log

#Script of precondition:Bandwidth
fio --ioengine=libaio --direct=1 --thread --norandommap --filename=$filename --name=init_seq2 --output=$outdir/init_seq2.log --rw=write --bs=128k --numjobs=1 --iodepth=64 --loops=3
#128k Seq Read
nohup ./nmon -f -s 2 -c 1900 -m $outdir &
fio --ioengine=libaio --randrepeat=0 --norandommap --thread --direct=1 --group_reporting --name=mytest --ramp_time=60 --runtime=$runtime --time_based --numjobs=1 --iodepth=128 --filename=$filename --rw=read --bs=128k --output=$outdir/128K_seqR.log --log_avg_msec=1000 --write_iops_log=$outdir/128K_seqR_iops.log --write_lat_log=$outdir/128K_seqR_lat.log
#128k Seq Write
nohup ./nmon -f -s 2 -c 1900 -m $outdir &
fio --ioengine=libaio --randrepeat=0 --norandommap --thread --direct=1 --group_reporting --name=mytest --ramp_time=60 --runtime=$runtime --time_based --numjobs=1 --iodepth=128 --filename=$filename --rw=write --bs=128k --output=$outdir/128K_seqW.log --log_avg_msec=1000 --write_iops_log=$outdir/128K_seqW_iops.log --write_lat_log=$outdir/128K_seqW_lat.log

NVMe

cat nvme.sh

#!/bin/bash


filename=/dev/nvme1n1
outdir=/home/work/nvmetestfile
pre_runtime=7200
runtime=3600


#Script of precondition:4K IOPS
fio --ioengine=libaio --direct=1 --thread --norandommap --filename=$filename --name=init_seq --output=$outdirinit_seq.log --rw=write --bs=128k --numjobs=1 --iodepth=64 --loops=3
fio --ioengine=libaio --direct=1 --thread --norandommap --filename=$filename --name=init_rand --output=$outdirinit_rand.log --rw=randwrite --bs=4k --numjobs=8 --iodepth=32 --ramp_time=60 --runtime=$pre_runtime

#4k Random Read
nohup ./nmon -f -s 2 -c 1900 -m $outdir &
fio --ioengine=libaio --randrepeat=0 --norandommap --thread --direct=1 --group_reporting --name=mytest --ramp_time=180 --runtime=$runtime --time_based --numjobs=8 --iodepth=64 --filename=$filename --rw=randread --bs=4k

#4k Random Write
nohup ./nmon -f -s 2 -c 1900 -m $outdir &
fio --ioengine=libaio --randrepeat=0 --norandommap --thread --direct=1 --group_reporting --name=mytest --ramp_time=180 --runtime=$runtime --time_based --numjobs=8 --iodepth=64 --filename=$filename --rw=randwrite --bs=4k

#Script of precondition:latency
#4k Random Read latency
nohup ./nmon -f -s 2 -c 1900 -m $outdir &
taskset -c 20 fio --ioengine=libaio --randrepeat=0 --norandommap --thread --direct=1 --group_reporting --name=mytest --ramp_time=180 --runtime=$runtime --time_based --numjobs=1 --iodepth=1 --filename=$filename --rw=randread --bs=4k --output=$outdir/nvme0n14K_randR_latency.log --log_avg_msec=1000 --write_lat_log=$outdir/nvme0n14K_randR_1_1.log

#4k Random Write latency
nohup ./nmon -f -s 2 -c 1900 -m $outdir &
taskset -c 20 fio --ioengine=libaio --randrepeat=0 --norandommap --thread --direct=1 --group_reporting --name=mytest --ramp_time=180 --runtime=$runtime --time_based --numjobs=1 --iodepth=1 --filename=$filename --rw=randwrite --bs=4k --output=$outdir/nvme0n14K_randW_latency.log --log_avg_msec=1000 --write_lat_log=$outdir/nvme0n14K_randW_1_1.log


#Script of precondition:Bandwidth
fio --ioengine=libaio --direct=1 --thread --norandommap --filename=$filename --name=$outdir/init_seq2 --output=$outdir/init_seq2.log --rw=write --bs=128k --numjobs=1 --iodepth=64 --loops=3

#128k Seq Read
nohup ./nmon -f -s 2 -c 1900 -m $outdir &
fio --ioengine=libaio --randrepeat=0 --norandommap --thread --direct=1 --group_reporting --name=mytest --ramp_time=180 --runtime=$runtime --time_based --numjobs=1 --iodepth=256 --filename=$filename --rw=read --bs=128k

#128k Seq Write
nohup ./nmon -f -s 2 -c 1900 -m $outdir &
fio --ioengine=libaio --randrepeat=0 --norandommap --thread --direct=1 --group_reporting --name=mytest --ramp_time=180 --runtime=$runtime --time_based --numjobs=1 --iodepth=256 --filename=$filename --rw=write --bs=128k

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是常见性能测试面试题目及答案,供参考: 1. 什么是性能测试?为什么要进行性能测试? 答:性能测试是一种测试类型,用于评估系统在特定条件下的响应时间、吞吐量、资源利用率和稳定性等方面的表现。进行性能测试可以发现系统中的瓶颈,优化系统,提高用户体验并确保系统在高负载条件下稳定运行。 2. 性能测试的阶段是什么?请简要介绍每个阶段的内容。 答:性能测试的阶段通常包括:需求分析、测试计划、测试设计、测试执行、测试分析和报告。其中,需求分析阶段是为了确定测试的目的、范围和目标用户;测试计划阶段是为了制定测试计划,包括测试策略、测试环境、测试工具和测试资源等;测试设计阶段是为了设计测试场景、测试数据和测试用例;测试执行阶段是为了执行测试并记录测试结果;测试分析阶段是为了分析测试结果并发现系统中的瓶颈;报告阶段是为了总结测试结果并提出优化建议。 3. 性能测试中的常见指标有哪些?请简要介绍每个指标的含义。 答:性能测试中的常见指标包括响应时间、吞吐量、并发用户数、资源利用率和稳定性等。其中,响应时间指用户发出请求到收到响应的时间;吞吐量指单位时间内能处理的请求数量;并发用户数指系统能同时处理的用户数;资源利用率指系统资源的利用率,包括 CPU、内存、磁盘和网络等;稳定性指系统在高负载条件下的稳定运行能力。 4. 性能测试中的负载模型有哪些?请简要介绍每个负载模型的特点。 答:性能测试中的负载模型包括均衡负载、逐步增加负载、峰值负载和压力测试等。其中,均衡负载指在测试期间保持稳定的负载;逐步增加负载指逐步增加负载直到系统达到极限;峰值负载指在某个时间点内突然增加负载,测试系统的瞬时响应能力;压力测试指在长时间内保持高负载,测试系统的稳定性。 5. 性能测试中的常用工具有哪些?请简要介绍每个工具的特点。 答:性能测试中的常用工具包括 LoadRunner、JMeter、Gatling、Locust 和 Artillery 等。其中,LoadRunner 是商业工具,支持多种协议和平台;JMeter 是开源工具,支持多种协议和插件;Gatling 是基于 Scala 的开源工具,支持高并发和多协议;Locust 是 Python 编写的开源工具,支持分布式和多协议;Artillery 是 Node.js 编写的开源工具,支持多协议和分布式测试。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值