Home  >  Article  >  Java  >  Detailed graphic explanation of jmeter stress testing tool in Java

Detailed graphic explanation of jmeter stress testing tool in Java

黄舟
黄舟Original
2017-08-22 10:26:592332browse

This article mainly provides you with a detailed introduction to the jmeter stress testing tool, which has certain reference value. Interested friends can refer to it

What is stress testing

As the name suggests: Stress test is the system being tested. Under certain access pressure, see whether the program is running stably/the server is running stably (resource occupancy)

For example: 2000 When users go shopping on a shopping website at the same time, will the page opening speed of these users slow down, or will the website crash?

Common tools for stress testing

Stress testing generally requires the use of tools, which cannot be done manually. The most commonly used tool is LoadRunner, but LoadRunner is a paid software after all, and it is also relatively complicated to use. Now more and more people are starting to use Jmeter to do stress testing. It's free and very easy to use.

The steps for stress testing are as follows:

1. Write a script or record a script

2. Use user-defined parameters

3. Scene design

4. Use the controller to control how many users are simulated.

5. Use the listener to view the test results

Examples of stress testing in this article

The examples cited in this article are: Use on a computer Jmeter simulates 200 users and uses Bing to search for different keywords to check whether the page return time is within the normal range.

Step one: Use CSVDataSetConfig to parameterize

First we put the two parameters needed for testing in a txt file. Create a new data.txt file and enter some data. There are two data in one line, separated by commas.

Start Jmeter, first add a Thread Group, and then add a CSV Data Set Config (Add -> Config Element -> CSV Data Set Config)

Second step:Add HTTP Request.

We add http request and send get tohttp: //cn.bing.com/search?q=Blog Garden+Little Tank

Select Thread Group and right-click (Add ->Sampler -> HTTP Request). The data that needs to be filled in is as follows:

Step 3:Use Thread Group to control how many users are simulated

Select Thread Group

Number of Threads(users): One user occupies one thread, 200 threads simulate 200 users

Ramp-Up Period(in seconds): Set threads How long does it take to start everything up. If the number of threads is 200 and the preparation time is 10, it takes 1 second to start 20 threads. That is, 20 threads are started per second.

Loop Count: The number of times each thread sends requests. If the number of threads is 200 and the number of loops is 10, then each thread sends 10 requests. The total number of requests is 200*10=2000. If "Always" is checked, all threads will keep sending requests until you choose to stop running the script.

Step 4:Add Summary Report to view test results

Right-click on the Thread Group (Add -> Listener -> Summary Report)

Step 5: Run it

So far, the script is all written. Let’s run it and see how it works. Below are the test results

The above is the detailed content of Detailed graphic explanation of jmeter stress testing tool in Java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn