Linux伺服器效能壓力測試

散盡浮華發表於2017-09-20

 

對於新採購的伺服器,需要進行有必要的效能測試。這裡選擇UnixBench工具進行效能測試。記錄如下:

1)安裝使用
下面的指令碼使用了最新版UnixBench5.1.3來測試,註釋了關於graphic的測試項(大多數VPS都是沒有顯示卡或者是集顯,所以影象效能無需測試),執行10-30分鐘後(根據CPU核心數量,運算時間不等)得出分數,越高越好。(提前將UnixBench5.1.3.tgz下載到了伺服器的/root目錄下了)

[root@test-vm001 ~]# cat bench.sh
#! /bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#===============================================================================================
#   Description:  Unixbench for Test
#===============================================================================================
# Create new soft download dir
mkdir -p /opt/unixbench;
mv /root/UnixBench5.1.3.tgz /opt/unixbench;
cd /opt/unixbench;
# Download UnixBench5.1.3
#if [ -s UnixBench5.1.3.tgz ]; then
#  echo "UnixBench5.1.3.tgz [found]"
#else
# echo "UnixBench5.1.3.tgz not found!!!download now......"
# if ! wget -c http://byte-unixbench.googlecode.com/files/UnixBench5.1.3.tgz;then
#	echo "Failed to download UnixBench5.1.3.tgz,please download it to "/opt/unixbench" directory manually and rerun the install script."
#	exit 1
# fi
#fi
tar -xzf UnixBench5.1.3.tgz;
cd UnixBench;
yum -y install gcc gcc-c autoconf gcc-c++ time perl-Time-HiRes
#Run unixbench
sed -i "s/GRAPHIC_TESTS = defined/#GRAPHIC_TESTS = defined/g" ./Makefile
make;
./Run;
echo '';
echo '';
echo '';
echo "======= Script description and score comparison completed! ======= ";
echo '';
echo '';
echo '';

二、測試結果
執行後返回的測試結果類似如下(該效能測試指令碼大概會執行10-30分鐘,需耐心等待測結果):

[root@test-vm001 ~]# sh -x bench.sh
+ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin
+ export PATH
+ mkdir -p /opt/unixbench
+ mv /root/UnixBench5.1.3.tgz /opt/unixbench
+ cd /opt/unixbench
+ tar -xzf UnixBench5.1.3.tgz
+ cd UnixBench
+ yum -y install gcc gcc-c autoconf gcc-c++ time perl-Time-HiRes
.........
.........
make[1]: Leaving directory `/opt/unixbench/UnixBench'
sh: 3dinfo: command not found

   #    #  #    #  #  #    #          #####   ######  #    #   ####   #    #
   #    #  ##   #  #   #  #           #    #  #       ##   #  #    #  #    #
   #    #  # #  #  #    ##            #####   #####   # #  #  #       ######
   #    #  #  # #  #    ##            #    #  #       #  # #  #       #    #
   #    #  #   ##  #   #  #           #    #  #       #   ##  #    #  #    #
    ####   #    #  #  #    #          #####   ######  #    #   ####   #    #

   Version 5.1.3                      Based on the Byte Magazine Unix Benchmark

   Multi-CPU version                  Version 5 revisions by Ian Smith,
                                      Sunnyvale, CA, USA
   January 13, 2011                   johantheghost at yahoo period com


1 x Dhrystone 2 using register variables  1 2 3 4 5 6 7 8 9 10

1 x Double-Precision Whetstone  1 2 3 4 5 6 7 8 9 10

1 x Execl Throughput  1 2 3

1 x File Copy 1024 bufsize 2000 maxblocks  1 2 3

1 x File Copy 256 bufsize 500 maxblocks  1 2 3

1 x File Copy 4096 bufsize 8000 maxblocks  1 2 3

1 x Pipe Throughput  1 2 3 4 5 6 7 8 9 10

1 x Pipe-based Context Switching  1 2 3 4 5 6 7 8 9 10

1 x Process Creation  1 2 3

1 x System Call Overhead  1 2 3 4 5 6 7 8 9 10

1 x Shell Scripts (1 concurrent)  1 2 3

1 x Shell Scripts (8 concurrent)  1 2 3

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: test-vm001: GNU/Linux
   OS: GNU/Linux -- 3.10.0-514.el7.x86_64 -- #1 SMP Tue Nov 22 16:42:41 UTC 2016
   Machine: x86_64 (x86_64)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz (4390.8 bogomips)
          x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
   17:31:42 up  8:11,  6 users,  load average: 0.14, 0.09, 0.06; runlevel 3

------------------------------------------------------------------------
Benchmark Run: 六 9月 16 2017 17:31:42 - 17:59:59
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       31665236.6 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     4345.5 MWIPS (9.9 s, 7 samples)
Execl Throughput                               4163.9 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1091117.9 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          299689.6 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       2535441.2 KBps  (30.0 s, 2 samples)
Pipe Throughput                             1556494.1 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 362875.3 lps   (10.0 s, 7 samples)
Process Creation                              10440.1 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   5115.9 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    726.5 lpm   (60.1 s, 2 samples)
System Call Overhead                        2707740.8 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   31665236.6   2713.4
Double-Precision Whetstone                       55.0       4345.5    790.1
Execl Throughput                                 43.0       4163.9    968.3
File Copy 1024 bufsize 2000 maxblocks          3960.0    1091117.9   2755.3
File Copy 256 bufsize 500 maxblocks            1655.0     299689.6   1810.8
File Copy 4096 bufsize 8000 maxblocks          5800.0    2535441.2   4371.5
Pipe Throughput                               12440.0    1556494.1   1251.2
Pipe-based Context Switching                   4000.0     362875.3    907.2
Process Creation                                126.0      10440.1    828.6
Shell Scripts (1 concurrent)                     42.4       5115.9   1206.6
Shell Scripts (8 concurrent)                      6.0        726.5   1210.8
System Call Overhead                          15000.0    2707740.8   1805.2
                                                                   ========
System Benchmarks Index Score                                        1482.1

+ echo ''

+ echo ''

+ echo ''

+ echo '======= Script description and score comparison completed! ======= '
======= Script description and score comparison completed! ======= 
+ echo ''

+ echo ''

+ echo ''

注意:上面會有兩個跑分結果,一個是 1 parallel process 的結果,另一個是4 parallel process 的結果 (具體可以看html裡的輸出)。兩者的區別即一個是單程式跑,一個是多程式跑 。
預設測試完成後測試結果會存放在results目錄,如下:

[root@test-vm001 results]# pwd
/opt/unixbench/UnixBench/results
[root@test-vm001 results]# ls
test-vm001-2017-09-16-01  test-vm001-2017-09-16-01.html  test-vm001-2017-09-16-01.log

results目錄中的三個檔案,第一個是和上面指令碼執行的結果一樣;第二個html檔案是將結果以頁面的形式展示出來,可以使用瀏覽器開啟檢視;第三個log檔案是執行過程中的詳細測試過程部分。

三、測試專案分析

測試過程中每個專案後面會有1 2 3 4 5 6 7 8 9 10 數字,意思是進行了10組測試,測試過程中部分內容及解釋如下:

1. ***********************
Dhrystone 2 using register variables  1 2 3 4 5 6 7 8 9 10
此項產生於 1984,測試 string handling,因為沒有浮點操作,所以深受軟體和硬體設計(hardware and software design)、編譯和連結(compiler and linker options)、程式碼優化(code optimazaton)、對記憶體的cache(cache memory)、等待狀態(?wait states)整數資料型別(integer data types)的影響

2. ******************** Double-Precision Whetstone 1 2 3 4 5 6 7 8 9 10 這一項測試浮點數操作的速度和效率。這一測試包括幾個模組,每個模組都包括一組用於科學計算的操作。覆蓋面很廣的一系列c函式:sin,cos,sqrt,exp,log 被用於整數和浮點數的數學運算、陣列訪問、條件分支(conditional branch)和程式呼叫。此測試同時測試了整數和浮點數算術運算。
3. ************** System Call Overhead 1 2 3 4 5 6 7 8 9 10 測試進入和離開作業系統核心的代價,即一次系統呼叫的代價。它利用一個反覆地呼叫 getpid 函式的小程式達到此目的。 4. *************** Pipe Throughput 1 2 3 4 5 6 7 8 9 10 管道(pipe)是程式間交流的最簡單方式,這裡的 Pipe throughtput 指的是一秒鐘內一個程式可以向一個管道寫 512 位元組資料然後再讀回的次數。需要注意的是,pipe throughtput 在實際程式設計中沒有對應的真實存在。 5. ************* Pipe-based Context Switching 1 2 3 4 5 6 7 8 9 10 這個測試兩個程式(每秒鐘)通過一個管道交換一個不斷增長的整數的次數。這一點很向現實程式設計中的一些應用,這個測試程式首先建立一個子程式,再和這個子程式進行雙向的管道傳輸。 6. ************ Process Creation 1 2 3 測試每秒鐘一個程式可以建立子程式然後收回子程式的次數(子程式一定立即退出)。process creation 的關注點是新程式程式控制塊(process control block)的建立和記憶體分配,即一針見血地關注記憶體頻寬。一般說來,這個測試被用於對作業系統程式建立這一系統呼叫的不同實現的比較。 7. *********** Execl Throughput 1 2 3 此測試考察每秒鐘可以執行的 execl 系統呼叫的次數。 execl 系統呼叫是 exec 函式族的一員。它和其他一些與之相似的命令一樣是 execve() 函式的前端。 8. *********** File copy 測試從一個檔案向另外一個檔案傳輸資料的速率。每次測試使用不同大小的緩衝區。這一針對檔案 read、write、copy 操作的測試統計規定時間(預設是 10s)內的檔案 read、write、copy 操作次數。 Filesystem Throughput 1024 bufsize 2000 maxblocks 1 2 3 Filesystem Throughput 256 bufsize 500 maxblocks 1 2 3 Filesystem Throughput 4096 bufsize 8000 maxblocks 1 2 3 9. ********** Shell Scripts 測試一秒鐘內一個程式可以併發地開始一個 shell 指令碼的 n 個拷貝的次數,n 一般取值 1,2,4,8.(我的系統上取 1, 8, 16)。這個指令碼對一個資料檔案進行一系列的變形操作(?transformation)。 Shell Scripts (1 concurrent) 1 2 3 Shell Scripts (8 concurrent) 1 2 3 Shell Scripts (16 concurrent) 1 2 3

可以對多臺伺服器效能進行如上測試,然後對比上面9個測試引數的結果值。 

相關文章