JMeter is a test tool that generally puts a constant access load on a Web system. It is difficult to increase or decrease the access load with the normal function, but I will introduce it because it can be realized graphically and easily by incorporating an external library (Throughput Shaping Timer).
--You can control the access load with a high degree of freedom. --One Jmeter can control the access load for each of multiple thread groups ↑ Access load control image from the official page
I think the following examples apply as cases that can be used when actually conducting load tests.
--I want to check the stability of the system by rapidly increasing (suddenly dropping) the load from the steady state during the test. --I want to test a system with a wave of access ――I want to carry out detailed tests at the same time for each thread group (access lead)
I will explain how much the access load can be controlled, including the actual settings.
Environmental information
Apache httpd server
This time it's a simple test, so I'll build it quickly with Docker. If you have a system to be tested, you do not need to build it. Whether it's Nginx or building a local environment, anything is fine!
$ docker pull httpd
$ docker run -dit --name my-apache-app -p 8080:80 -v "$PWD":/usr/local/apache2/htdocs/ httpd:2.4
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e2dc7c3714ee httpd:2.4 "httpd-foreground" 21 minutes ago Up 21 minutes 0.0.0.0:8080->80/tcp, 0.0.0.0:32768->8080/tcp my-apache-app
$ docker exec -it e2dc7c3714ee /bin/bash
$ echo "hello" > ./htdocs/index.html
Here, the shocking fact that the document root of apache is the home directory of Mac is discovered. .. ..
URL http://localhost:8080/index.html
Java
Java 8 or above is required to run JMeter. I will omit how to install Java. [Even beginners can easily understand] How to install JDK for Mac
$ java -version java version "1.8.0_202" Java(TM) SE Runtime Environment (build 1.8.0_202-b08) Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
JMeter
Download JMeter and extract it to any directory Download page
Download ThroughputShapingTimer Download page
<JMeter extracted directory> /apache-jmeter-5.3/lib
$ cd/apache-jmeter-5.3/bin $ sh ./jmeter.sh
jmeter.bat
in the same layer.
That's all for preparation, the long-awaited practice!Mr. A "This system usually has 100tps access, so I will test it with a load of 10 minutes from JMeter!" Boss "Usually that's about it, but what if Twitter buzzes and the amount of access momentarily increases five times?" Mr. A "Hmm ... I don't know ... (Nanyaro ...)"
A spectacular performance test of Mr. A and JMeter begins here!
The basic operation of JMeter is omitted.
Add a thread group Since the execution time is controlled by ThroughputShapingTimer, set the number of loops to infinity.
Add an HTTP request sampler
--Protocol: http
--Server name or IP: localhost
--Port number: 8080
--Path: /index.html
Add a statistical report
--File name: Specify an arbitrary save destination
Add Throughput Shaping Timer
Set the load amount
Method of operation:
-Click ʻAdd Rowto add a setting row * Rows will be in chronological order --Set the load amount at the start to
Start RPS * RPS = RequestPerSecond --Set the load amount at the end to ʻEnd RPS
--Set the duration to Duration, sec
When set, the graph will be drawn in real time at the bottom of the screen, so let's try it out!
Run a thread group
The number of accesses is almost as planned.
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e2dc7c3714ee httpd:2.4 "httpd-foreground" 7 hours ago Up 36 minutes 0.0.0.0:8080->80/tcp, 0.0.0.0:32771->8080/tcp my-apache-app
$ docker logs e2dc7c3714ee | grep test01 | awk '{print $4}' | sed 's/\[12\/Oct\///g' | uniq -c 1 2020:14:38:12 1 2020:14:39:09 3 2020:14:39:10 4 2020:14:39:11 6 2020:14:39:12 8 2020:14:39:13 11 2020:14:39:14 10 2020:14:39:15 9 2020:14:39:16 11 2020:14:39:17 10 2020:14:39:18 9 2020:14:39:19 11 2020:14:39:20 10 2020:14:39:21 9 2020:14:39:22 11 2020:14:39:23 10 2020:14:39:24 10 2020:14:39:25 10 2020:14:39:26 9 2020:14:39:27 11 2020:14:39:28 10 2020:14:39:29 10 2020:14:39:30 10 2020:14:39:31 10 2020:14:39:32 9 2020:14:39:33 11 2020:14:39:34 17 2020:14:39:35 26 2020:14:39:36 34 2020:14:39:37 42 2020:14:39:38 51 2020:14:39:39 41 2020:14:39:40 35 2020:14:39:41 26 2020:14:39:42 17 2020:14:39:43 10 2020:14:39:44 10 2020:14:39:45 10 2020:14:39:46 10 2020:14:39:47 10 2020:14:39:48 10 2020:14:39:49 9 2020:14:39:50 11 2020:14:39:51 10 2020:14:39:52 10 2020:14:39:53 10 2020:14:39:54 9 2020:14:39:55 10 2020:14:39:56 11 2020:14:39:57 10 2020:14:39:58 10 2020:14:39:59 10 2020:14:40:00 9 2020:14:40:01 11 2020:14:40:02 10 2020:14:40:03 10 2020:14:40:04
The first item is the amount of access per second, and the second item is the time. You can see that the load has temporarily increased to 50 RPS by keeping about 10 RPS.
Mr. A who succeeded in manipulating the access load freely with JMeter Mr. A "Increased access assuming when buzzing on Twitter, it seems that you can test with JMeter!" Boss: "I was shown the results, but I can only test on a single page. I'd like you to test assuming that the user goes from the top page to the popular page." Mr. A who was floating, but the real battle was yet to come ** Next time: "I'm not afraid of anything anymore" **
It was a brief explanation, but I hope you felt the possibility of ThroughputShapingTime. However, it is highly unlikely that you will only access the sample pages when testing a web application. This time, I will only introduce simple usage, and in the next article, I will explain practical usage.
ThrouputShapingTimer DockerHub Apache httpd
Recommended Posts