測試 VPS 硬碟讀寫速度

·

在 VPS 主機中要測試硬碟讀寫速度,其中一個簡單的方法是用 hdparm 指令,也有人會用 dd if 指令來測試,只是我覺得 dd 太暴力了,很多主機商不喜歡你這麼做,hdparm 指令必較溫和些,主要是用來測試 SSD 硬碟。

在測試時盡可能在系統處於閒置狀態,比較少人使用母雞時,這樣測試的數據才會較為準確。

hdparm 測試

先安裝 hdparm

CentOS 系統

yum install hdparm

debian / ubuntu 系統

apt-get install hdparm

以下的例子是用 hdparm 測試 GCP SSD 硬碟 /dev/sda 的讀寫速度:

測試硬碟讀取的速度:

hdparm -t /dev/sda
/dev/sda:
 Timing buffered disk reads: 730 MB in  3.00 seconds = 243.18 MB/sec

讀取速度是每秒 243.18 MB,可以測試幾次,數值會比較準確。

測試硬碟寫入的速度:

hdparm -t --direct /dev/sda

/dev/sda:
 Timing O_DIRECT disk reads: 738 MB in  3.00 seconds = 245.93 MB/sec

寫入速度是每秒 245.93 MB,可以測試幾次,數值會比較準確。

結語

GCP 主機的硬碟沒有想像中的快,與 Linode VPS 比起來,真的差很多,下面是 Linode 4G VPS 測試的結果,做個參考。

hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads: 4234 MB in  3.00 seconds = 1411.25 MB/sec

2018/09/01 補充:

nench.sh 是一個不錯的測試腳本,可以測試 CPU 及 IO:

  • loosely based on the established freevps.us/bench.sh
  • includes CPU and ioping measurements
  • reduced number of speedtests (9 x 100 MB), while retaining useful European and North American POPs
  • runs IPv6 speedtest by default (if the server has IPv6 connectivity)
  • has a 10-second timeout for each speedtest, so you don’t end up waiting 10 minutes for that one slow speedtest from halfway around the globe — but thanks to the power of curl -w, you still get to see what speed your server achieved during those 10 seconds
  • successfully tested on Arch Linux, Debian, FreeBSD, and Ubuntu

開發者有特別說明,請在一個新的服務器上做測試,誰都不能保證腳本有沒有問題,基本上,使用 nench.sh 風險自負。

nench.sh 腳本說明:

https://github.com/haydenjames/bench-scripts

運行腳本:

(curl -s wget.racing/nench.sh | bash; curl -s wget.racing/nench.sh | bash) 2>&1 | tee nench.log

(wget -qO- wget.racing/nench.sh | bash; wget -qO- wget.racing/nench.sh | bash) 2>&1 | tee nench.log
hosted by kinsta

Comments

在〈測試 VPS 硬碟讀寫速度〉中有 2 則留言

    1. 「yungke」的個人頭像

      這一篇文章太久了,感謝您的回覆提醒。
      GCP 的硬碟要開大一點,效能 (速度) 會更好喔~

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

Hey, 想嘗試 Kinsta 主機嗎?

18748

Kinsta 高效能主機

wPowered Starter 方案

馬上訂購

18749
Your Mastodon Instance