1. 程式人生 > >Linux服務器性能壓力測試

Linux服務器性能壓力測試

mips 定時 utc tex 5.0 -s locks dir 使用

對於新采購的服務器,需要進行有必要的性能測試。這裏選擇UnixBench工具進行性能測試。記錄如下:

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

[[email protected] ~]# 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分鐘,需耐心等待測結果):

[[email protected] ~]# 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目錄,如下:

[[email protected] results]# pwd
/opt/unixbench/UnixBench/results
[[email protected] 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個測試參數的結果值。

Linux服務器性能壓力測試