100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > [MySQL]-压力测试之性能监测指标

[MySQL]-压力测试之性能监测指标

时间:2022-09-17 18:53:44

相关推荐

[MySQL]-压力测试之性能监测指标

[MySQL]-压力测试之性能监测指标

森格 | 12月

本文主要是介绍在数据库的压测过程中,要时刻的一些指标,尤其是当数据库的性能达到瓶颈时,要注意哪个指标已经打满。

一、前文回顾

在前面量两篇文章中,分别介绍了两款压测数据库的工具,Sysbench 与 TPCC-MySQL,大家可以点击链接回顾一下(大概需要10分钟)。在压力测试中,我们不断增加并发数去获取当前数据库配置下的最大性能(QPS、TPS、TPMC等)。

今天呢,我们来注意下在这过程中,是哪些方面的原因导致了性能达到了瓶颈。

二、机器配置

对于压力测试前,我们需要对我们的机器大概的配置有一个了解,在这里个人写了个shell脚本供大家做参考:

#!/bin/sh#Date:10月21日#author:liangsen#echo -e "\033[41;30;30mI will show computer Infomation there\033[0m"echo ""echo -e "\033[44;30;30m====================CPU========================\033[0m"grep "model name" /proc/cpuinfoecho ""echo -e "\033[44;30;30m================Memory Size====================\033[0m"grep MemTotal /proc/meminfoecho ""echo -e "\033[44;30;30m=================32/64Bit=======================\033[0m"getconf LONG_BITecho ""echo -e "\033[44;30;30m===============Linux version====================\033[0m"cat /etc/redhat-releaseecho ""echo -e "\033[44;30;30m=================Linux Core=====================\033[0m"uname -recho ""echo -e "\033[44;30;30m============HardDisk And Partition==============\033[0m"df -hecho ""echo -e "\033[44;30;30m=====================IP==========================\033[0m"ifconfigecho "gateWay"cat /etc/sysconfig/networkecho "DNS"cat /etc/resolv.confecho ""echo -e "\033[44;30;30m=====================HostName==========================\033[0m"hostnameecho ""

该脚本分别展示了机器的CPU、内存、位数、Linux版本、Linux内核版本、磁盘和分区情况、IP地址以及主机名称。

三、性能监测

对于测试的性能,我们可以从几个方面来观察,分别是 CPU、磁盘、内存、网络。

注:在压力测试过程,如果想要测试到最佳的性能,最好压测机和被压测机分开来。

工具

这里使用dstat来对几个指标进行监测。dstat结合了vmstat,iostat,ifstat,netstat以及更多的信息, 实时显示统计情况,输出报告, 在分析和排障时可以通过启用监控项并排序, 模块化设计,使用python编写的,方便扩展现有的工作任务。

安装:

# 使用 yum 安装hostname>yum install dstat# 检测是否安装成功hostname>dstat

查看dstat参数:

Usage: dstat [-afv] [options..] [delay [count]]Versatile tool for generating system resource statisticsDstat options:-c, --cpu enable cpu stats-C 0,3,total include cpu0, cpu3 and total-d, --disk enable disk stats-D total,hda include hda and total-g, --page enable page stats-i, --int enable interrupt stats-I 5,eth2 include int5 and interrupt used by eth2-l, --load enable load stats-m, --mem enable memory stats-n, --net enable network stats-N eth1,totalinclude eth1 and total-p, --proc enable process stats-r, --ioenable io stats (I/O requests completed)-s, --swap enable swap stats-S swap1,total include swap1 and total-t, --time enable time/date output-T, --epoch enable time counter (seconds since epoch)-y, --sys enable system stats--aio enable aio stats--fs, --filesystemenable fs stats--ipc enable ipc stats--lock enable lock stats--raw enable raw stats--socketenable socket stats--tcp enable tcp stats--udp enable udp stats--unix enable unix stats--vm enable vm stats--plugin-nameenable plugins by plugin name (see manual)--list list all available plugins-a, --all equals -cdngy (default)-f, --full automatically expand -C, -D, -I, -N and -S lists-v, --vmstat equals -pmgdsc -D total--bits force bits for values expressed in bytes--floatforce float values on screen--integer force integer values on screen--bw, --blackonwhite change colors for white background terminal--nocolor disable colors (implies --noupdate)--noheaders disable repetitive headers--noupdate disable intermediate updates--output filewrite CSV output to file--profile show profiling statistics when exiting dstat

对我们来说,用到 -cdrmngy就足以:

hostname>dstat -cdrmngy

total-cpu-usage:

dsk/total:

net/total:

paging(系统的分页活动):

system(系统统计):

四、总结

在压测过程中,需要我们时刻监测这些性能指标,并去分析哪个指标是是性能达到瓶颈的关键因素,从而可以更好地去进行性能优化。以上仅为个人总结,如有不对之处欢迎大佬们指导。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。