“This is the third day of my participation in the November Gwen Challenge. See details of the event: The last Gwen Challenge 2021”.
preface
Start with a question :” Does performance testing really care about having a performance monitoring platform?”
Which is more important, server resource monitoring or performance test metrics monitoring?
Answer:
Not very care about, care about is just icing on the cake! According to? Performance testing isn't about staring at fancy charts all the time! Instead, it needs comprehensive analysis to find the bottleneck of service performance, and after optimization, it can improve service performance! So the second question is nonsense. All indicators are related to each other, not independent indicators.Copy the code
So why do so many people spend so much time building a performance test monitoring platform?
First: In order to make up for the deficiency of JMeter performance test tool in report output, if the Loadrunner performance test tool can provide rich report output, then there is no need to spend so much time.
Second: Xiuer, icing on the cake, junior and intermediate performance testing engineers need such auxiliary skills to show that they have complete performance testing skills.
How do you do performance testing with JMeter?
- Jmeter itself is a GUI tool developed 100% in Java; As indicated when starting JMeter, it is recommended to use NoGUI mode, which means executing scripts in CLI mode, if you are performing performance tests.
So how do you collect test results?
-
To make up for the lack of output in jMeter reporting, it has a wealth of plug-ins to monitor server resources and performance test indicators, such as < InfluxDB, Prometheus >+Grafana solutions.
-
How can you use JMeter for performance testing without these plug-ins? This requires the performance test engineer to have a strong technical background: understanding the system architecture, service architecture, features of each framework, and performance tuning.
A solution to insufficient monitoring resources for JMeter performance testing:
First: debugging scripts in GUI mode is not suitable for performance testing; To avoid performance problems caused by testing tools, the NoGUI mode command jmeter -n -t xxx.jtl -l xxx.jtl -o report is generally used
Second: CLI mode is not wrong, but there is a problem: as the performance test lasts longer, the HTML report generation process will occupy the load machine system resources, and may interrupt the test or report cannot be generated properly;
Thirdly, there are uncertainty factors whether JTL files are too large to generate reports or report output fails. Then we can only use Linux commands to monitor server resources: top, vmstat, free, iostat, etc.
Fourth: in Linux, in addition to commands, you can also use nmon tools to collect system resources and download them to local excel and analyze the performance test results in the process of executing Jmeter test scripts;
Fifth: so how to monitor Vuser, RT, TPS/QPS and other performance indicators? When using JMeter, you can modify the configuration file to change the result of the JTL file, both to control the size of the result file and to facilitate performance analysis with server resource data.
Performance monitoring platform principles
Why is the principle stuck in the middle? No, this is just a supplement!!
In the past, using JMeter to complete the performance test, one is to use the monitoring plug-in and the other is to log in to the Linux server for real-time monitoring, which is not good for data persistence. That is to say, once the performance test is stopped,
Once the environment is restored, it is impossible to analyze the results generated by JMeter in a timely manner. Therefore, it is necessary to build a visual performance monitoring platform and make the data persistent. Convenient for comparative analysis after the event.
The article “Building a Monitoring Platform for JMeter+Grafana+Influxdb+Telegraf Performance Test Environment” has been published before, which is based on binary installation package.
To sum up, there is today’s Docker container deployment scheme:
Any real-time database that JMeter runs on (Prometheus/IFluxDB) reports data only to find system bottlenecks for service performance testing.
1. Prepare the Docker environment
Apt-get install -y docker. IO # yum install -y docker # prom/prometheus docker pull grafana/grafanaCopy the code
Start Node-exporter:
# monitor Linux server resources plugin: CPU, memory, disk docker run -d p 9100:9100 \ -v "/proc:/host/proc:ro" \ -v "/sys:/host/sys:ro" \ -v "/:/rootfs:ro" \ --net="host" \ prom/node-exporterCopy the code
Access the address: http://127.0.0.1:9100/metrics; As follows:
3, startup configuration before Prometheus: mkdir/data/Prometheus && vim/data/Prometheus Prometheus. Yml
Time series database that collects monitoring data reported by other services
global: scrape_interval: 60s evaluation_interval: 60s scrape_configs: - job_name: prometheus static_configs: - targets: ['localhost:9090'] labels: instance: prometheus - job_name: linux static_configs: - targets: [' 192.168.2.217:9100 '] Labels: instance: 212-linux-job_name: jmeter Static_configs: -targets: [' 192.168.2.212:9100] labels: instance: 212-jmeter # docker start Prometheus docker run -d \ -p 9090:9090 \ -v /data/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \ prom/prometheusCopy the code
Access the address: http://127.0.0.1:9090/graph and http://127.0.0.1:9090/targets
Common directories before starting Grafana:
Grafana can add Prometheus, InfluxDB, and mysql database resources
Mkdir /data/grafana-storage chmod 777-r /data/grafana-storage docker start grafana docker run -d \ -p 300:3000 \ --name=grafana \ -v /data/grafana-storage:/var/lib/grafana \ grafana/grafanaCopy the code
Visit http://127.0.0.1:3000/
Grafana add data source, create report, template address: grafana.com/grafana/das… ; You can import the template you want
The most difficult part is to create a report, which requires data sequence database fields and SQL methods. It is best to find templates to save time and effort!
6, Jmeter development performance test script, add listener, others have done a good jmeterMonitor: github.com/Germey/JMet…
Principle of the Jmeter-Promethes-Plugin: Turn JMeter into a Data Exporter for Prometheus to export;
Run the container, place the script in the corresponding host mapping volume, execute the script when the container is started, and report to Prometheus in real time
7, About jmeters-Promethes-plugin: github.com/johrstrom/j…
Skip =true MVN clean package – dmaven.test.skip =true