4

Linux 性能测试实践

 3 years ago
source link: https://wsgzao.github.io/post/linux-performance/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Linux 性能测试、监控、优化是一个持续的过程,上图为 LinuxCon 上 Brendan D. Gregg 分享的 Linux benchmarking tools 示意图,涵盖面十分广泛。我们可以通过成熟的监控方案如 BMC Patrol,Zabbix 来捕获大部分信息,在实际工作中我们会经常关注 I/O 性能,一般可以使用 dd/ORION/IOzone 做简单的测试,如果需要获取更加全面详细的报告可以使用 nmon,本文将主要介绍 Super PI /dd/nmon 三种简单而有效的监测方法。

CPU | Memory | I/O | Network 一个都不能少


2015 年 03 月 06 日 - 初稿

阅读原文 - https://wsgzao.github.io/post/linux-performance/


确认 CPU 型号

cat /proc/cpuinfo |grep "model name"|uniq|cut -f2 -d:

Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz

Super PI

计算时间越短越好

time echo "scale=500;4*a(1)"|bc -l -q

3.141592653589793238462643383279502884197169399375105820974944592307\
81640628620899862803482534211706798214808651328230664709384460955058\
22317253594081284811174502841027019385211055596446229489549303819644\
28810975665933446128475648233786783165271201909145648566923460348610\
45432664821339360726024914127372458700660631558817488152092096282925\
40917153643678925903600113305305488204665213841469519415116094330572\
70365759591953092186117381932611793105118548074462379962749567351885\
75272489122793818301194912

real 0m0.081s
user 0m0.076s
sys 0m0.000s

每次做读写测试前建议先清空缓存

sync; echo 3 > /proc/sys/vm/drop_caches

测试读性能

选择测试磁盘,建议做 2-3 组取平均值

hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  1074 MB in  3.00 seconds = 357.92 MB/sec

测试写入性能

根据业务选择不同的 BlockSize 大小按需多次测试取平均值

time dd if=/dev/zero of=/tmp/speed bs=1M count=2K conv=fsync;rm /tmp/speed

以 10,000 rpm 300 GB SAS 硬盘为例,机型为 IBM x3650 M4,Raid 参数如下

1.Read Policy:Ahead (控制器缓存读策略:预读)
2.Write Policy:Write Back with BBU(控制器缓存写策略:有电池备份时回写)
3.IO Policy: Direct(IO 策略:直接)
4.Drive Cache:disable (硬盘缓存:禁用)

Raid Read(MB) Write(MB) Raid 1 170 130 Raid 5 350 250 Raid 10 300 215

建议根据实际需求配置间隔时间和次数,配合 nmon Analyser 可以显示直观的图表数据

#author: OX
#function: monitor system information
#time:2015/03/06
#crontab -e
#0 0 * * * sh /tmp/nmon/nmon.sh >/dev/null 2>&1
npath=/tmp/nmon/log
# monitoring per 120 senonds
#nmon -s 120 -c 720 -f -m $npath
# monitoring per 300 senonds
/tmp/nmon/nmon_x86_sles11 -s 300 -c 288 -f -m $npath
#delete file before 365 day
#find /tmp -name *.nmon  -mtime +365 -exec rm {} \;

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK