壓力測試
用來測試系統效能及好壞
取得系統資訊
lscpu lsmem lspci
測試 network (iperf3)
安裝工具 iperf3
- centos
yum install https://iperf.fr/download/fedora/iperf3-3.1.3-1.fc24.x86_64.rpm -y
- debian
wget https://iperf.fr/download/ubuntu/iperf3_3.1.3-1_amd64.deb wget https://iperf.fr/download/ubuntu/libiperf0_3.1.3-1_amd64.deb dpkg -i iperf3_3.1.3-1_amd64.deb libiperf0_3.1.3-1_amd64.deb
測試網路頻寬
啟動 server 端 iperf3 -s 啟動 client 端 (測試 100G 雙向) iperf3 -c <server ip> -n 100G -R -i 10 -P 10 && iperf3 -c <server ip> -n 100G -i 10 -P 10
其他參數
Usage: iperf [-s|-c host] [options]
iperf [-h|--help] [-v|--version]
Server or Client:
-p, --port # server port to listen on/connect to
-f, --format [kmgKMG] format to report: Kbits, Mbits, KBytes, MBytes
-i, --interval # seconds between periodic bandwidth reports
-F, --file name xmit/recv the specified file
-A, --affinity n/n,m set CPU affinity
-B, --bind <host> bind to a specific interface
-V, --verbose more detailed output
-J, --json output in JSON format
--logfile f send output to a log file
-d, --debug emit debugging output
-v, --version show version information and quit
-h, --help show this message and quit
Server specific:
-s, --server run in server mode
-D, --daemon run the server as a daemon
-I, --pidfile file write PID file
-1, --one-off handle one client connection then exit
Client specific:
-c, --client <host> run in client mode, connecting to <host>
-u, --udp use UDP rather than TCP
-b, --bandwidth #[KMG][/#] target bandwidth in bits/sec (0 for unlimited)
(default 1 Mbit/sec for UDP, unlimited for TCP)
(optional slash and packet count for burst mode)
-t, --time # time in seconds to transmit for (default 10 secs)
-n, --bytes #[KMG] number of bytes to transmit (instead of -t)
-k, --blockcount #[KMG] number of blocks (packets) to transmit (instead of -t or -n)
-l, --len #[KMG] length of buffer to read or write
(default 128 KB for TCP, 8 KB for UDP)
--cport <port> bind to a specific client port (TCP and UDP, default: ephemeral port)
-P, --parallel # number of parallel client streams to run
-R, --reverse run in reverse mode (server sends, client receives)
-w, --window #[KMG] set window size / socket buffer size
-C, --congestion <algo> set TCP congestion control algorithm (Linux and FreeBSD only)
-M, --set-mss # set TCP/SCTP maximum segment size (MTU - 40 bytes)
-N, --no-delay set TCP/SCTP no delay, disabling Nagle's Algorithm
-4, --version4 only use IPv4
-6, --version6 only use IPv6
-S, --tos N set the IP 'type of service'
-L, --flowlabel N set the IPv6 flow label (only supported on Linux)
-Z, --zerocopy use a 'zero copy' method of sending data
-O, --omit N omit the first n seconds
-T, --title str prefix every output line with this string
--get-server-output get results from server
--udp-counters-64bit use 64-bit counters in UDP test packets
--no-fq-socket-pacing disable fair-queuing based socket pacing
測試硬碟 IO (fio)
安裝工具 fio
- debian
apt install fio
- centos
yum install fio
寫設定檔
設定檔可以快速的測試各種參數
nano /fio.conf
[global] # where to test io filename=/dev/sdb/jobfile.fio size=10g io_size=10g ioengine=libaio group_reporting wait_for_previous [4kSeqRead] name=4kSeqRead bs=4k readwrite=read [4kSeqwirte] name=4kSeqwirte bs=4k readwrite=write [4kRandRead] name=4kRandRead bs=4k readwrite=randread [4kRandwrite] name=4kRandwrite bs=4k readwrite=randwrite [4mSeqRead] name=4mSeqRead bs=4m readwrite=read [4mSeqwirte] name=4mSeqwirte bs=4m readwrite=write [4mRandRead] name=4mRandRead bs=4m readwrite=randread [4mRandwrite] name=4mRandwrite bs=4m readwrite=randwrite
執行測試
fio fio.conf rm jobfile.fio
測試 CPU & memory speed (sysbench)
安裝 sysbench
https://github.com/akopytov/sysbench
Debian/Ubuntu curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh | sudo bash sudo apt -y install sysbench RHEL/CentOS: curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh | sudo bash sudo yum -y install sysbench
測試 CPU 效能
執行測試 30s 算質數數量
sysbench --threads=1 --time=60 cpu run
結果以 total number of events 作為性能基準
root@pve1:/vm-storage# sysbench --threads=1 cpu --cpu-max-prime=1000 --time=30 run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Prime numbers limit: 1000
Initializing worker threads...
Threads started!
CPU speed:
events per second: 18476.94
General statistics:
total time: 30.0001s
total number of events: 554357
Latency (ms):
min: 0.05
avg: 0.05
max: 1.45
95th percentile: 0.06
sum: 29875.48
Threads fairness:
events (avg/stddev): 554357.0000/0.00
execution time (avg/stddev): 29.8755/0.00
測試
以 total number of events 作為性能基準
sysbench --threads=1 --time=60 memory --memory-total-size=1024G run