[JAVA] Set the access load that can be changed graphically with JMeter (Part 1)

Introduction

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).

What you can do with 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 sample_image ↑ 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.

Try using Throughput Shaping Timer

Environmental information

Environmental information

Environment

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!

  1. Get the official image
$ docker pull httpd
  1. Start container
$ docker run -dit --name my-apache-app -p 8080:80 -v "$PWD":/usr/local/apache2/htdocs/ httpd:2.4
  1. Confirm container ID
$ 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
  1. Container connection
$ docker exec -it e2dc7c3714ee /bin/bash
  1. Create test page
$ echo "hello" > ./htdocs/index.html

Here, the shocking fact that the document root of apache is the home directory of Mac is discovered. .. ..

  1. Check connection with browser URL http://localhost:8080/index.html
    スクリーンショット 2020-10-12 17.06.51.png

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

  1. Download JMeter and extract it to any directory Download page スクリーンショット 2020-10-12 22.30.25.png

  2. Download ThroughputShapingTimer Download page

  1. Place ThroughputShapingTimer Extract the downloaded plug-in (jpgc-tst-2.5.zip) and unzip it. Place the following three jar files included in it in Jmeter's lib directory. Location: <JMeter extracted directory> /apache-jmeter-5.3/lib
  1. Start JMeter
 $ cd  /apache-jmeter-5.3/bin
$ sh ./jmeter.sh

Try setting the load amount (Beginner)

Situation settings

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!

Try setting Jmeter

The basic operation of JMeter is omitted.

  1. Add a thread group Since the execution time is controlled by ThroughputShapingTimer, set the number of loops to infinity. スクリーンショット 2020-10-12 23.40.44.png

  2. Add an HTTP request sampler --Protocol: http --Server name or IP: localhost --Port number: 8080 --Path: /index.html スクリーンショット 2020-10-12 23.34.25.png

  3. Add a statistical report --File name: Specify an arbitrary save destination スクリーンショット 2020-10-12 23.19.04.png

  4. Add Throughput Shaping Timer スクリーンショット 2020-10-12 23.20.41.png スクリーンショット 2020-10-12 23.22.32.png

  5. 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 toStart RPS * RPS = RequestPerSecond --Set the load amount at the end to ʻEnd RPS --Set the duration to Duration, sec スクリーンショット 2020-10-12 23.25.07.png When set, the graph will be drawn in real time at the bottom of the screen, so let's try it out!

  6. Run a thread group スクリーンショット 2020-10-12 23.36.07.png

Check the execution result

Statistical report

The number of accesses is almost as planned. スクリーンショット 2020-10-12 23.43.36.png

Apache log

  1. Confirm container ID
$ 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
  1. Apache log analysis
 $ 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.

Later talk

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" **

at the end

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.

reference

ThrouputShapingTimer DockerHub Apache httpd

Recommended Posts

Set the access load that can be changed graphically with JMeter (Part 2)
Set the access load that can be changed graphically with JMeter (Part 1)
Four-in-a-row with gravity that can be played on the console
Introduction to Java that can be understood even with Krillin (Part 1)
About the problem that the server can not be started with rails s
[Rails] "pry-rails" that can be used when saving with the create method
A description that only the poster can access
Organize methods that can be used with StringUtils
[Ruby] Methods that can be used with strings
About the matter that hidden_field can be used insanely
Load test with JMeter
Connect to Access database with Java [UCan Access] * Set until it can be executed with VS Code
The world of Azure IoT that can be played on the DE10-Nano board: Ajuchika with FPGA !!?
Learning Ruby with AtCoder Beginners Selection [Some Sums] Increase the methods that can be used
Summary of css selectors that can be used with Nookogiri
Create a page control that can be used with RecyclerView
Firebase-Realtime Database on Android that can be used with copy
File form status check sheet that can be deleted with thumbnails
SwiftUI View that can be used in combination with other frameworks
Summary of JDK that can be installed with Homebrew (as of November 2019)