Linux command – Stressful Application Test

Loading

Stressful Application Test (stressapptest) 程式可以在 memory 到 processor 與 I/O 之間產生大量的隨機流量,主要用於模擬系統在高負載情況下的壓力測試,他現在屬於 apache 2.0 license.連 google 也使用這工具是確保系統在高負載下的穩定性.

測試環境為 Ubuntu16.04 64bits,從 apt-get 就可以安裝.

root@ubuntu:~# apt-get install stressapptest
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-59 linux-headers-4.4.0-59-generic
  linux-image-4.4.0-59-generic linux-image-extra-4.4.0-59-generic
Use 'apt autoremove' to remove them.
The following NEW packages will be installed:
  stressapptest
0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 127 kB of archives.
After this operation, 377 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 stressapptest amd64 1.0.6-2 [127 kB]
Fetched 127 kB in 2s (42.4 kB/s)        
Selecting previously unselected package stressapptest.
(Reading database ... 243155 files and directories currently installed.)
Preparing to unpack .../stressapptest_1.0.6-2_amd64.deb ...
Unpacking stressapptest (1.0.6-2) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up stressapptest (1.0.6-2) ...

如果是在 CentOS 7 下可以透過官方網站 https://github.com/stressapptest/stressapptest ,或是透過 git 下載後編譯來使用.

[root@localhost Downloads]# git clone https://github.com/stressapptest/stressapptest.git
Cloning into 'stressapptest'...
remote: Counting objects: 277, done.
remote: Total 277 (delta 0), reused 0 (delta 0), pack-reused 277
Receiving objects: 100% (277/277), 317.75 KiB | 264.00 KiB/s, done.
Resolving deltas: 100% (187/187), done.
[root@localhost Downloads]# cd stressapptest
[root@localhost stressapptest]# ./configure
configure: Compiling with dynamically linked libraries.
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
...
[root@localhost stressapptest]# make
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /root/Downloads/stressapptest/missing --run aclocal-1.11 
...
[root@localhost stressapptest]# make install

官方網站說明 stressapptest 適合用於下列幾種測試

  • Stress test: 壓力測試
  • 可當作硬體的驗證與除錯工具
  • 記憶體測試.
  • 硬碟測試.

先來看一下 stressapptest 給的範例 ,測試 256MB 的記憶體 20 秒 並使用參數 8 “warm copy” threads, 以及 8 cpu load threads.

root@ubuntu:~# stressapptest -s 20 -M 256 -m 8 -C 8 -W 
Log: Commandline - stressapptest -s 20 -M 256 -m 8 -C 8 -W
Stats: SAT revision 1.0.6_autoconf, 64 bit binary
Log: buildd @ kapok on Wed Jan 21 17:09:35 UTC 2015 from open source release
Log: 1 nodes, 1 cpus.
Log: Prefer plain malloc memory allocation.
Log: Using memaligned allocation at 0x7ff70959c000.
Stats: Starting SAT, 256M, 20 seconds
Log: Region mask: 0x1
Log: Seconds remaining: 10
Stats: Found 0 hardware incidents
Stats: Completed: 132896.00M in 28.31s 4694.65MB/s, with 0 hardware incidents, 0 errors
Stats: Memory Copy: 132896.00M at 6588.09MB/s
Stats: File Copy: 0.00M at 0.00MB/s
Stats: Net Copy: 0.00M at 0.00MB/s
Stats: Data Check: 0.00M at 0.00MB/s
Stats: Invert Data: 0.00M at 0.00MB/s
Stats: Disk: 0.00M at 0.00MB/s

Status: PASS - please verify no corrected errors

使用的參數:

  • -s seconds : Number of seconds to run
  • -M mbytes : Megabytes of ram to test
  • -m threads : Number of memory copy threads to run
  • -C threads : Number of memory CPU stress threads to run.
  • -W : Use more CPU-stressful memory copy

要將結果導成檔案可以使用參數 -l 想要知道更多的測試結果可以自行調整 verbosity 值.

  • -l logfile : log output to file ‘logfile’ (none)
  • -v level : verbosity (0-20) (default: 8)

看一下執行結果

Stats: Completed: 263982.00M in 20.00s 13197.76MB/s, with 0 hardware incidents, 0 errors
Stats: Memory Copy: 263982.00M at 13200.27MB/s

可以看到只有 Memoey 有流量,其他如 File Copy, Net Copy, Data Check, Invert Data, Disk 皆為 0 .其他流量要如何產生呢!

  • File Copy , Diskhttps://benjr.tw/96762
    File 與 Disk 都是透過硬碟來跟記憶體做存取,不同的是 Disk 是直接使用 RAW Disk 做存取, File 需要在格式化的硬碟空間才能使用.
  • Net Copyhttps://benjr.tw/96766
    可以透過網路來進行測試,需要使用兩台機器來測試外部網路,或是單機的內部網路.
  • Data Check , Invert Datahttps://benjr.tw/96776
    用來測試記憶體,一般的 thread 會將資料從一個區塊複製到另一個區塊 (可以指定是不是要做 Data Check),而 invert thread 會原地反轉資料
  • CPU-Cachehttps://benjr.tw/96768
    用來測試多處理器的快取一致性(cache coherency ).
  • Local NUMA / Remote NUMAhttps://benjr.tw/96797
    用來測試 NUMA (Non-uniform memory access – CPU 與記憶體區分成不同的結點 Node ,不同的 CPU 各自擁有記憶體). Local NUMA 該節點上的程序成功配置到該節點的記憶體空間. Remote NUMA 該節點上的程序,成功配置到另一個節點的記憶體空間.

stressapptest 參數參考表 http://manpages.ubuntu.com/manpages/zesty/man1/stressapptest.1.html

沒有解決問題,試試搜尋本站其他內容

4 thoughts on “Linux command – Stressful Application Test

發佈留言

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

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料