AWS EBS Magnetic(standard)磁盤性能測試

背景html

最近公司的一臺實例類型爲m5.2xlarge(8個vCPU,32G的Memory)的機器磁盤性能不行,因而須要作個磁盤性能測試。這裏使用fio測試工具。sql


1.AWS磁盤類型簡介bash

AWS EC2 instance 目前EBS有5種類型,分別是gp2,io1,st1,sc1,standard. 筆者只介紹standard,其餘四種可自行上網瞭解。dom

standard是AWS上一代的volumn HDD類型,卷大小1G-1T,最大IOPS 40-200,最大吞吐量40-90M/s;ide


Previous Generation Volumes
Volume Type EBS Magnetic
Description Previous generation HDD
Use Cases Workloads where data is infrequently accessed
API Name standard
Volume Size 1 GiB-1 TiB
Max. IOPS/Volume 40–200
Max. Throughput/Volume 40–90 MiB/s
Max. IOPS/Instance 80,000
Max. Throughput/Instance 1,750 MiB/s
Dominant Performance Attribute IOPS


2.fio工具簡介,安裝工具

(1)fio是專門用來測試磁盤性能的一種好用工具,有順序讀,順序寫,順序讀寫,隨機讀,隨機寫,隨機讀寫等模式,本篇只測試順序讀和隨機讀,不測試寫。性能

安裝fio很是簡單,直接使用yum install -y fio便可。測試


注意ui

使用fio測試寫的時候,會損害磁盤上已經存在的數據,嚴重的話會致使系統奔潰,起不來。spa

(不要問我爲何知道,由於這是血和淚的教訓,筆者曾把一臺已有數據的EC2實例磁盤測試死掉,包括根磁盤和數據盤兩塊盤,最後怎麼都起不來,辛虧有AMI能夠恢復。)


(2)經常使用參數介紹

filename=/dev/sdb1       指定測試的文件設備

directory 存儲文件的目錄

direct=1                 測試過程繞過機器自帶的buffer,使測試結果更真實。

bs=16k                   單次io的塊文件大小爲16k

size=2g                  指定測試文件大小爲2g,不指定這個參數,默認是當前磁盤的所有大小

numjobs=30               指定測試線程爲30.

runtime=1000 測試時間爲1000秒

time_based=1              : Keep running until runtime/timeout is met

ioengine=psync           io引擎使用pync方式

rw=randwrite             測試隨機寫的I/O

name  指定此次job的名稱

iodepth : Number of IO buffers to keep in flight

randrepeat            : Use repeatable random IO pattern

--output=test.sql  將結果輸出到指定文件中

allow_mounted_write=1 容許寫入測試

rwmixread               : Percentage of mixed workload that is reads

rwmixwrite              : Percentage of mixed workload that is writes


rw值:

read 順序讀

write 順序寫

randread 隨機讀

randwrite 隨機寫

rw或readwrite 順序混合讀寫

randrw 隨機混合讀寫


3.測試腳本

爲了便於測試和收集結果,筆者寫了個簡單的測試腳本以下:

#!/bin/bash

. ~/.bash_profile
set -u
set -x
set -e
BASEDIR=/usr/local/fio
cd $BASEDIR
exec 3>&1 4>&2 1>> fio.log 2>&1

FILENAME=/dev/nvme2n1p1
DIRECT=1
#RW=read
RWS="read randread"
RANDREPEAT=0
IOENGINE=libaio
BSS="8 16 32 64 128 256 1024"
IODEPTH=8
TIME_BASED=1
RUNTIME=180
NAME=read
for rw in `echo "${RWS}"`
do
  for bs in `echo "${BSS}"`
  do
  /bin/fio --filename=${FILENAME} --direct=${DIRECT} --rw=${rw} --randrepeat=${RANDREPEAT} --ioengine=${IOENGINE} --bs=${bs}k --iodepth=${IODEPTH} --time_based=${TIME_BASED} --runtime=${RUNTIME} --name=${NAME} --output=${rw}_${bs}.txt
  sleep 3
  done
done


4.測試結果整理分析


bs(K) Read_IOPS Read_BW(MIB/s) Randread_IOPS Randread_BW(MIB/s)
8 1593 12.4 1687 13.2
16 966 15.1 955 14.9
32 956 29.9 915 28.6
64 911 56 981 61.4
128 746 93.3 786 98.3
256 686 172 711 178
1024 242 243 246 246


(1)順序讀和隨機讀的IOPS對比圖

blob.png


(2)順序讀和隨機讀的吞吐量對比圖

blob.png

5.結論

(本結論僅針對本次實驗結果,由於測試樣本不足可能致使測試結果不許)

(1)吞吐量=IOPS*bs/1024

(2)順序讀和順序寫IOPS和吞吐量差距不大。

(3)磁盤的吞吐量存在瓶頸250MIB/s,若是須要更高性能的BW,能夠考慮使用AWS推薦的gp2。


參考連接

Amazon EBS Volume Types

Benchmark EBS Volumes

相關文章
相關標籤/搜索