A powerful tool for pressure measurement-the use of Jmeter, a quick start to understand

Hello, I’m the code farmer Fei brother , I’ve always wanted to fly, and I’m running that old man for the time being.

Areas of expertise: Java high-concurrency programming, MySQL database The
focus of this article: record various commands for viewing logs in daily work.
It is full of dry goods, it is recommended to collect it, and you need to check it often. Friends who have questions and needs, welcome to leave a message~~~.

Article Directory

Preface

I’m Coder Fei, thank you for reading. As we all know, Jmeter is a powerful tool for pressure measurement interface. There are many components, which can cope with pressure testing requirements in various scenarios. Let us get to know this weapon below.

Introduction to core components

Component nameComponent roleHow to add components
Thread groupAll test plans are based on thread groupsInsert picture description here
HTTP requestUsed to set the requested interface address and input parametersInsert picture description here
HTTP header managerUsed for HTTP request interface to set the request headerInsert picture description here
View the result treeViewing the result tree will print the status of each requestInsert picture description here
Aggregate reportThe aggregate report shows the number of all requests, the average response time of all requests, and the response time of 90% of the requestsInsert picture description here
Fixed timerUsed to set the time interval for each thread requestInsert picture description here

Thread group

All thread settings are in the thread group, you can think of the thread group as a thread pool.

Insert picture description here


Name: It is the personalized name of the
thread group. Several important attributes in the thread group:

  1. Number of threads: how many threads are set to execute the test, the threads here can be imagined as virtual users
  2. Ramp-up Period (in Seconds): Preparation time, that is, how long it takes to start all threads, the default is 0, in the above figure, it means that 5 threads are started at the same time. If it is set to 5, it means to start 5 threads within 5 seconds, and start one every second.
  3. Number of cycles: Forever, it means to call the interface in a continuous loop within the duration of the scheduler. The setting here is 3 times, which means that each thread executes 3 times in a loop.
    Scheduler configuration:
  4. Duration (seconds): indicates the duration of the pressure test
  5. Start-up delay (seconds): indicates how long to start the test

Http request

Insert picture description here


The basic settings of Http request are shown in the figure above:

  1. Protocol: can be set to http or https
  2. Server name or IP: If it is a domain name, set the domain name directly, otherwise set the ip address.
  3. Port number: only needed for IP access.
    HTTP request:
  4. Method: here are mainly GET and POST two request methods
  5. Path: It is the address of the interface.
    The box below is to set the request parameters
  6. If it is a form submission, set the parameters in Parameters
  7. If the content-type is application/json type, set the request parameters in Body Data
  8. If it is a multipart/form-data type, you need to set the parameters in Files upload.

HTTP header manager

Insert picture description here


Here, as the name suggests, is to set the HTTP request header information. You can set content-type and other information.

View the result tree

Insert picture description here


Viewing the result tree is also a very important component. This component mainly displays all HTTP requests. Of course, we can check Log errors only to display all wrong HTTP requests. Checking Successes will only show all successful requests. You can also persist the result of the request to a file.

Aggregate report

Insert picture description here


The aggregate report is a very important component. Through this component, we can know the results of the stress test as a whole. There are multiple lines in the list. I will explain the attributes of each line one by one:

  1. Samples: The total number of requests. There are 15 requests in total, and 5 threads loop 3 times.
  2. Average: Average response time, this indicator counts the average response time for all requests.
  3. Median: Median response time, this indicator counts the median response time.
    4. 90% Line: The average response time of 90% of requests. This is an important indicator of interface performance.
  4. 99% Line: The average response time of 99% of requests, this indicator is similar to the Average indicator
  5. Min: The fastest response time is the time taken to respond to the fastest request.
  6. Max: The slowest response time is the time it takes to respond to the slowest request.
    7. Error %: the proportion of wrong requests
  7. Throughput: the throughput of the interface
  8. Recevied KB/sec: The amount of received data per second
  9. Sent KB/sec: The amount of data sent per second

Fixed timer

Insert picture description here


This timer is mainly used to set the time interval of each thread loop. The 5000 milliseconds here means that each thread will wait 5 seconds before requesting the interface again.

to sum up

This article makes a brief summary of the use of Jmeter, and introduces the commonly used components needed to stress test an HTTP interface. Proficiency in using these components can easily cope with pressure testing requirements. The order of the pressure test settings is set to the thread group -> set HTTP request -> set HTTP request header -> set aggregate report -> set to view the result tree.