下载URL:https://github.com/akopytov/sysbench
安装sysbench之前需要安装以下依赖包:m4 autoconf automake libtool 。
使用 yum install 安装这几个依赖包。
# tar zxvf sysbench-1.0.4.tar.gz
# cd sysbench-1.0.4
# ./autogen.sh
# ./configure --without-mysql //不需要测试数据库,所以用--without选项
# make
# make install
IP:10.37.64.53
CUP:8 core
Mem:18G
OS:RHEL 6.3 (64 Bit)
-bash-4.1$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel Xeon E312xx (Sandy Bridge)
stepping : 1
cpu MHz : 2394.454
cache size : 4096 KB
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb lm constant_tsc rep_good unfair_spinlock pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm xsaveopt fsgsbase bmi1 smep erms
bogomips : 4788.90
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel Xeon E312xx (Sandy Bridge)
stepping : 1
cpu MHz : 2394.454
cache size : 4096 KB
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb lm constant_tsc rep_good unfair_spinlock pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm xsaveopt fsgsbase bmi1 smep erms
bogomips : 4788.90
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 2
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel Xeon E312xx (Sandy Bridge)
stepping : 1
cpu MHz : 2394.454
cache size : 4096 KB
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb lm constant_tsc rep_good unfair_spinlock pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm xsaveopt fsgsbase bmi1 smep erms
bogomips : 4788.90
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 3
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel Xeon E312xx (Sandy Bridge)
stepping : 1
cpu MHz : 2394.454
cache size : 4096 KB
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb lm constant_tsc rep_good unfair_spinlock pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm xsaveopt fsgsbase bmi1 smep erms
bogomips : 4788.90
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 4
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel Xeon E312xx (Sandy Bridge)
stepping : 1
cpu MHz : 2394.454
cache size : 4096 KB
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb lm constant_tsc rep_good unfair_spinlock pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm xsaveopt fsgsbase bmi1 smep erms
bogomips : 4788.90
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 5
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel Xeon E312xx (Sandy Bridge)
stepping : 1
cpu MHz : 2394.454
cache size : 4096 KB
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb lm constant_tsc rep_good unfair_spinlock pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm xsaveopt fsgsbase bmi1 smep erms
bogomips : 4788.90
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 6
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel Xeon E312xx (Sandy Bridge)
stepping : 1
cpu MHz : 2394.454
cache size : 4096 KB
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb lm constant_tsc rep_good unfair_spinlock pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm xsaveopt fsgsbase bmi1 smep erms
bogomips : 4788.90
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 7
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel Xeon E312xx (Sandy Bridge)
stepping : 1
cpu MHz : 2394.454
cache size : 4096 KB
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb lm constant_tsc rep_good unfair_spinlock pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm xsaveopt fsgsbase bmi1 smep erms
bogomips : 4788.90
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
利用sysbench评测CPU性能,线程数设成和CPU核数相同为8
-bash-4.1$ sysbench --threads=8 --events=10000 --time=120 --test=cpu --cpu-max-prime=200000 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any
options.
sysbench 1.0.4 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 8
Initializing random number generator from current time
Prime numbers limit: 200000
Initializing worker threads...
Threads started!
General statistics:
total time: 116.4856s
total number of events: 10000
Latency (ms):
min: 92.54
avg: 93.15
max: 119.90
95th percentile: 94.10
sum: 931541.67
Threads fairness:
events (avg/stddev): 1250.0000/0.71
execution time (avg/stddev): 116.4427/0.03
-bash-4.1$ sysbench --threads=8 --test=memory --memory-block-size=4K --memory-total-size=10G --memory-
oper=write run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.4 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 8
Initializing random number generator from current time
Initializing worker threads...
Threads started!
Operations performed: 2621440 (2111415.90 ops/sec)
10240.00 MiB transferred (8247.72 MiB/sec)
General statistics:
total time: 1.2393s
total number of events: 2621440
Latency (ms):
min: 0.00
avg: 0.00
max: 0.85
95th percentile: 0.00
sum: 4325.52
Threads fairness:
events (avg/stddev): 327680.0000/61070.57
execution time (avg/stddev): 0.5407/0.10
通过设置memory-block-size的值(如8K、4K、1K、128),测试一下内存写性能。
使用PostgreSQL自带的工具pg_test_fsync测试前,需要cd到需要测试的文件系统的某个目录下。
-bash-4.1$ pg_test_fsync
5 seconds per test
O_DIRECT supported on this platform for open_datasync and open_sync.
Compare file sync methods using one 8kB write:
(in wal_sync_method preference order, except fdatasync is Linux's default)
open_datasync 7495.343 ops/sec 133 usecs/op
fdatasync 7159.733 ops/sec 140 usecs/op
fsync 7675.694 ops/sec 130 usecs/op
fsync_writethrough n/a
open_sync 8455.910 ops/sec 118 usecs/op
Compare file sync methods using two 8kB writes:
(in wal_sync_method preference order, except fdatasync is Linux's default)
open_datasync 3994.309 ops/sec 250 usecs/op
fdatasync 7287.177 ops/sec 137 usecs/op
fsync 6976.354 ops/sec 143 usecs/op
fsync_writethrough n/a
open_sync 3936.843 ops/sec 254 usecs/op
Compare open_sync with different write sizes:
(This is designed to compare the cost of writing 16kB in different write
open_sync sizes.)
1 * 16kB open_sync write 7511.188 ops/sec 133 usecs/op
2 * 8kB open_sync writes 3880.634 ops/sec 258 usecs/op
4 * 4kB open_sync writes 1954.984 ops/sec 512 usecs/op
8 * 2kB open_sync writes 965.620 ops/sec 1036 usecs/op
16 * 1kB open_sync writes 489.129 ops/sec 2044 usecs/op
Test if fsync on non-write file descriptor is honored:
(If the times are similar, fsync() can sync data written on a different
descriptor.)
write, fsync, close 7481.958 ops/sec 134 usecs/op
write, close, fsync 7480.560 ops/sec 134 usecs/op
Non-sync'ed 8kB writes:
write 370970.939 ops/sec 3 usecs/op
生成数据
由于会读到缓存数据,影响测试结果。所以使用events来控制读请求次数。本次设为100000,由于block-size为8K,所以读取的数据总量为800M左右。
[root@sndsdevsdd02 test]# sysbench --threads=10 --events=100000 --test=fileio --file-block-size=8192 --file-test-mode=seqrd --file-fsync-mode=fdatasync prepare
清理缓存
读之前需要清理缓存,否则测试数据没意义
[root@sndsdevsdd02 test]# echo 1 > /proc/sys/vm/drop_caches
测试
[root@sndsdevsdd02 test]# sysbench --threads=10 --events=100000 --test=fileio --file-block-size=8192 --file-test-mode=seqrd --file-fsync-mode=fdatasync run
清理数据
[root@sndsdevsdd02 test]# sysbench --threads=10 --events=100000 --test=fileio --file-block-size=8192 --file-test-mode=seqrd --file-fsync-mode=fdatasync cleanup
修改参数,多次测试
threads=1,10,100,1000
file-block-size=8192
file-test-mode=seqwr,seqrd,rndwr,rndrd
file-fsync-mode=fdatasync
下载URL:ftp://ftp.netperf.org/netperf/
下载URL:http://nmon.sourceforge.net/pmwiki.php?n=Site.Download
在10.37.64.54机器上启动,使用默认端口
传输速度为770Mbit/s
[root@sndsdevsdd02 ~]# netperf -t TCP_STREAM -H 10.37.64.54 -l 5 -Cc
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 10.37.64.54 () port 0 AF_INET
Recv Send Send Utilization Service Demand
Socket Socket Message Elapsed Send Recv Send Recv
Size Size Size Time Throughput local remote local remote
bytes bytes bytes secs. 10^6bits/s % S % S us/KB us/KB
87380 16384 16384 5.00 769.73 0.31 1.50 0.262 1.278
单个连接
[root@sndsdevsdd02 ~]# netperf -t TCP_RR -H 10.37.64.54 -l 5 -Cc
MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 10.37.64.54 () port 0 AF_INET :
first burst 0
Local /Remote
Socket Size Request Resp. Elapsed Trans. CPU CPU S.dem S.dem
Send Recv Size Size Time Rate local remote local remote
bytes bytes bytes bytes secs. per sec % S % S us/Tr us/Tr
16384 87380 1 1 10.00 9862.43 1.23 1.29 9.945 10.430
16384 87380
多个连接的时候(同一个网段,连接时间设为10s),通过nmon查看网络packin/packout的最大值
连接数 pkgs/s
1 10087
10 74444
30 108130
60 165176
100 206103
150 221118
200 228998
连接数为200时,其中一个连接的输出如下:
MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 10.37.64.54 () port 0 AF_INET :
first burst 0
Local /Remote
Socket Size Request Resp. Elapsed Trans. CPU CPU S.dem S.dem
Send Recv Size Size Time Rate local remote local remote
bytes bytes bytes bytes secs. per sec % S % S us/Tr us/Tr
16384 87380 1 1 10.00 1015.97 32.63 32.67 2569.163 2572.770
16384 87380