本文作者:suxingrui
本文链接:https://blog.youkuaiyun.com/suxingrui/article/details/80793138
版权声明:本文为原创文章,转载请注明出处。
应用开发或维护过程中,有时候需要对特定的场景(接口等)进行性能测试。
使用一些辅导工具能够减轻我们的工作,从而把精力投入到更重要的性能优化中。
经过调研(感谢各位大神的博客论坛等),使用以下开源工具,具体教程请自行搜索。
当前调研基于Windows环境,Linux同理
指标监控
时序列数据源:prometheus-2.3.1.windows-amd64
监控展示平台:grafana-5.1.4
监控MySQL:mysqld_exporter-0.10.0.windows-amd64
添加配置my.cnf
,启动执行:mysqld_exporter.exe -config.my-cnf="my.cnf"
[client]
host=
user=
password=
监控Redis:redis_exporter-v0.19.1.windows-amd64
启动执行:redis_exporter.exe -redis.addr=redis://192.168.1.101:6379
监控服务器:node_exporter-0.16.0.linux-amd64(Linux),wmi_exporter-amd64(Windows)
启动执行:wmi_exporter.exe --collector.textfile.directory=E:\monitor\windows\wmi_exporter-amd64\textfile_inputs
监控Java应用JMX:jmx_prometheus_javaagent-0.10.jar
启动脚本中添加:-javaagent:libs/jmx_prometheus_javaagent-0.10.jar=9156:conf/jmx_prometheus_config.yaml -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=9157
配置jmx_prometheus_config.yaml
---
hostPort: localhost:9157
username:
password:
lowercaseOutputName: true
lowercaseOutputLabelNames: true
rules:
- pattern: ".*"
监控Java应用业务指标:添加Prometheus Java Client依赖
Spring Boot的Maven工程可使用:
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_spring_boot</artifactId>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_hotspot</artifactId>
<version>0.4.0</version>
</dependency>
Grafana展示的仪表板(Dashboards):
MySQL_Overview.json
prometheus-redis_rev1.json
windows-node_rev3.json
JMX-altassian-overview_rev1.json
应用业务指标需要自定义
压测工具
压测使用:gatling-charts-highcharts-bundle-2.3.1(路径不能有中文)
压测实时监控需要:influxdb-1.5.4-1
启动执行:influxd.exe -config influxdb.conf
Grafana展示:grafana_rev1.json