Summary of Performance Testing
Performance testing is a type of software testing that measures a system’s stability, scalability, reliability, speed, and resource usage. It identifies performance bottlenecks and ensures business needs are met. Performance testing is required for many systems, such as web applications, databases, and operating systems.
There are many types of performance tests, and some concepts are very similar:
- Load Testing
- Baseline Testing
- Smoke Testing
- Stress Testing
- Soak Testing
- Endurance Testing
- Capacity Testing
- Longevity Testing
- Peak Testing
- Spike Testing
- Volume Testing
- Capacity Tests
- Reliability Testing
- Scalability Testing
Tools for performance testing
Similarly, there are many tools for performance testing:
- Apache JMeter
- HP LoadRunner
- Gatling
- Blazemeter
- k6
- NeoLoad
- TestComplete
- Silk Performer
- Rational Performance Tester
- Apica LoadView
- AppDynamics
- Dynatrace
- New Relic
It’s hard to say which tool is the best, it depends on your needs and budget. If you want open source and easy to use, then JMeter is a good choice. If you want a commercial tool, try LoadRunner and NeoLoad. The important point is that no one tool can handle all performance tests, and many times we need to use them in combination.
Distributed testing of JMeter
In this article, I will introduce JMeter’s distributed testing in detail, which we often use for performance testing.
In the distributed test role, we need a control node Controller and multiple work node Workers. If you want your requests to increase, you can do so by continuously adding worker nodes. Controller controls Workers, but it does not run specific test cases. Workers are connected to the target system for specific testing.
The overall system architecture is roughly as follows:
Worker can be on different servers, so it is called distributed, and therefore it can use the resources of multiple computers to simulate enough requests.
Detailed steps
I will introduce step by step how to use JMeter distributed testing for performance testing. The general structure is as follows:
I run the Controller on a Mac, and I run the Workers through two Ubuntu servers. It should be noted that their IPs are on the same intranet. In order to save trouble for the target system, I directly request Bing, stackoverflow, QQ.
Step 1: Install JDK
Apache JMeter is written in Java and requires a Java runtime environment to run it. Install on Ubuntu as follows:
sudo apt install openjdk-11-jdk
Step 2: Download Apache JMeter
Go to the download page of the official website to download the latest JMeter package apache-jmeter-5.5.zip, and unzip it:
unzip apache-jmeter-5.5.zip
All nodes need to be downloaded and installed.
The location of Controller is as follows:
/Users/larry/Software/apache-jmeter-5.5
The location of Workers is as follows:
home/larry/software/apache-jmeter-5.5
You don’t have to have the same location as me, I listed it to correspond to the following commands.
Step 3: Prepare the JMX file for testing
JMeter stores all the test information in the jmx
file, open the tool to write the test case as follows:
Then define how to run the entire test, here is defined to use 8 threads, 60 seconds warm-up and 120 seconds duration:
I put the file here:
$ ls /Users/larry/Software/apache-jmeter-5.5/projects/pkslow performance-test.jmx
In my case, only the Controller needs this jmx
file, but the Worker does not. They can interact via RMI.
Step 4: Start Workers
To start Workers first, start it in server mode. After starting, it will not perform any tests. It will wait for the Controller and instructions connected to it:
- Worker 1:
$ /home/larry/software/apache-jmeter-5.5/bin/jmeter-server -Dserver.rmi.ssl.disable=true -Djava.rmi.server.hostname=192.168.50.171 Created remote object: UnicastServerRef2 [liveRef: [endpoint:[192.168.50.171:41709](local), objID:[-2af2edf6:1882245cfde:-7fff, 1980465993472976097]]]
- Worker 2:
$ /home/larry/software/apache-jmeter-5.5/bin/jmeter-server -Dserver.rmi.ssl.disable=true -Djava.rmi.server.hostname=192.168.50.60 Created remote object: UnicastServerRef2 [liveRef: [endpoint:[192.168.50.60:45337](local),objID:[18489452:1882246a88b:-7fff, 4749047852254882466]]]
”
Note: A java.rmi.RemoteException may be encountered if you do not specify the parameter:
java.rmi.server.hostname
.
$ ./software/apache-jmeter-5.5/bin/jmeter-server -Dserver.rmi.ssl.disable=true May 15, 2023 5:43:16 PM java.util.prefs.FileSystemPreferences$1 run INFO: Created user preferences directory. Created remote object: UnicastServerRef2 [liveRef: [endpoint:[127.0.1.1:33021](local), objID:[-7155c199:1881ecaf233:-7fff, -6972385484103483700]]] Server failed to start: java.rmi.RemoteException: Cannot start. ubuntu is a loopback address. An error occurred: Cannot start. ubuntu is a loopback address.
Step 5: Start Controller
After all the Workers are in place, wait for the coach to give an order. When starting, specify the jmx file, the location where the report is generated, and the IP of the Worker, as follows:
$ cd /Users/larry/Software/apache-jmeter-5.5/ $ ./bin/jmeter -n -t projects/pkslow/performance-test.jmx -l projects/pkslow/performance-test.csv -e -o projects/pkslow/Reports -Dserver.rmi.ssl.disable=true - R 192.168.50.171, 192.168.50.60 Creating summarizer <summary> Created the tree successfully using projects/pkslow/performance-test.jmx Configuring remote engine: 192.168.50.171 Configuring remote engine: 192.168.50.60 Starting distributed test with remote engines: [192.168.50.171, 192.168.50.60] @ May 16, 2023 10:37:31 PM CST (1684247851079) Remote engines have been started:[192.168.50.171, 192.168.50.60] Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445 summary + 1 in 00:00:02 = 0.7/s Avg: 1260 Min: 1260 Max: 1260 Err: 0 (0.00%) Active: 2 Started: 2 Finished: 0 summary + 111 in 00:02:31 = 0.7/s Avg: 4433 Min: 41 Max: 50474 Err: 4 (3.60%) Active: 15 Started: 16 Finished: 1 summary = 112 in 00:02:33 = 0.7/s Avg: 4405 Min: 41 Max: 50474 Err: 4 (3.57%) summary + 64 in 00:00:19 = 3.3/s Avg: 25706 Min: 62 Max: 66745 Err: 31 (48.44%) Active: 0 Started: 16 Finished: 16 summary = 176 in 00:02:52 = 1.0/s Avg: 12151 Min: 41 Max: 66745 Err: 35 (19.89%) Tidying up remote @ May 16, 2023 10:40:24 PM CST (1684248024629) ... end of run
More information can be viewed in jmeter.log:
$ tail -f jmeter.log 2023-05-16 22:40:29,956 INFO o.a.j.r.d.JsonExporter: Found data for consumer statisticsSummary in context 2023-05-16 22:40:29,957 INFO o.a.j.r.d.JsonExporter: Creating statistics for overall 2023-05-16 22:40:29,957 INFO o.a.j.r.d.JsonExporter: Creating statistics for other transactions 2023-05-16 22:40:29,957 INFO o.a.j.r.d.JsonExporter: Checking output folder 2023-05-16 22:40:29,958 INFO o.a.j.r.d.JsonExporter: Writing statistics JSON to /Users/larry/Software/apache-jmeter-5.5/projects/pkslow/Reports/statistics.json 2023-05-16 22:40:30,006 INFO o.a.j.r.d.ReportGenerator: Exporting data using exporter:'html' of className:'org.apache.jmeter.report.dashboard.HtmlTemplateExporter' 2023-05-16 22:40:30,007 INFO o.a.j.r.d.HtmlTemplateExporter: Will generate dashboard in folder: /Users/larry/Software/apache-jmeter-5.5/projects/pkslow/Reports 2023-05-16 22:40:30,142 INFO o.a.j.r.d.HtmlTemplateExporter: Report will be generated in: /Users/larry/Software/apache-jmeter-5.5/projects/pkslow/Reports, creating folder structure 2023-05-16 22:40:30,145 INFO o.a.j.r.d.TemplateVisitor: Copying folder from '/Users/larry/Software/apache-jmeter-5.5/bin/report-template' to '/Users/larry/Software/apache -jmeter-5.5/projects/pkslow/Reports', got message: /Users/larry/Software/apache-jmeter-5.5/projects/pkslow/Reports, found non empty folder with following content [/Users/larry/Software/ apache-jmeter-5.5/projects/pkslow/Reports/statistics.json], will be ignored 2023-05-16 22:40:30,472 INFO o.a.j.JMeter: Dashboard generated
Worker will also start working and print some simple logs after receiving instructions:
$ /home/larry/software/apache-jmeter-5.5/bin/jmeter-server -Dserver.rmi.ssl.disable=true -Djava.rmi.server.hostname=192.168.50.171 Created remote object: UnicastServerRef2 [liveRef: [endpoint:[192.168.50.171:44621](local), objID:[4d13369d:18824fd059a:-7fff, 2287886479123818682]]] Starting the test on host 192.168.50.171 @ 2023 May 16 22:37:31 HKT (1684247851980) Warning: Nashorn engine is planned to be removed from a future JDK release Finished the test on host 192.168.50.171 @ 2023 May 16 22:40:24 HKT (1684248024679)
Step 6: Results and Report
After the entire test is run, you can find the corresponding results:
$ ls -l /Users/larry/Software/apache-jmeter-5.5/projects/pkslow/ total 72 drwxr-xr-x 6 larry staff 192 May 16 22:40 Reports -rw-r--r-- 1 larry staff 23472 May 16 22:40 performance-test.csv -rw-r--r-- 1 larry staff 10593 May 16 09:50 performance-test.jmx
Open index.html directly in the Reports directory:
Other tips
Change the port of the Worker
The default port of Worker is 1099, but it can be changed, and sometimes it must be changed, such as setting up a firewall, or starting multiple Workers on the same Server. The specific commands are as follows:
$ /home/larry/software/apache-jmeter-5.5/bin/jmeter-server -Dserver.rmi.ssl.disable=true -Djava.rmi.server.hostname=192.168.50.60 -Dserver_port=1984
Of course, the Controller also needs to adjust its commands synchronously:
$ ./bin/jmeter -n -t projects/pkslow/performance-test.jmx -l projects/pkslow/performance-test.csv -e -o projects/pkslow/Reports -Dserver.rmi.ssl.disable =true -R 192.168.50.171:1984,192.168.50.60:1984
Run tests with nohup
Performance tests sometimes need to run for a long time, it is recommended to use nohup mode to run:
$ nohup ./bin/jmeter -n -t projects/pkslow/performance-test.jmx -l projects/pkslow/performance-test.csv -e -o projects/pkslow/Reports -Dserver.rmi.ssl. disable=true -R 192.168.50.171:1984,192.168.50.60:1984 & [1] 81248
Add time when specifying results
In this way, it is very clear when it starts to run, and it also avoids errors in the directory.
$ nohup ./bin/jmeter -n -t projects/pkslow/performance-test.jmx -l projects/pkslow/performance-test."$(date + %F.%T)".csv - e -o projects/pkslow/Reports-"$(date + %F.%T)" -Dserver.rmi.ssl.disable=true -R 192.168.50.171:1984,192.168.50.60:1984 &
However, you should also pay attention to regularly cleaning up unnecessary results, so as not to take up hard disk space.
Summary
Performance testing is very important, and Apache JMeter is open source and easy to use, and can be used in projects.
Finally: In order to give back to the hard-core fans, I have compiled a complete software testing video learning tutorial for you. Friends can get free 【Guaranteed 100% Free】
code>
Join my software testing exchange group: 110685036 to get it for free~ (Academic exchanges with fellow leaders, and there will be live broadcasts to share technical knowledge points every night)
Software testing interview applet
The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!
The following interview question sections are covered:
1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux
6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics
How to obtain a full set of information:
The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge Cloud native entry skill treeHomepageOverview 12835 people are studying systematically