Jmeter simple stress test

        Jmeter is a very useful stress testing tool. Jmeter is very suitable for lightweight stress testing. It only takes ten minutes to write the scripts required for stress testing.

1. What is a stress test 

        As the name implies: stress test is the system to be tested, under a certain access pressure, to see whether the program runs stably/server runs stably (resource occupancy)

        For example: 2000 users go to a shopping website to shop at the same time, whether these users will slow down the speed of opening the page, or whether the website will crash.

 

2. Common tools for stress testing

        To do a stress test, you generally need to use tools, which cannot be done manually. The most commonly used tool is LoadRunner, but LoadRunner is a paid software after all, and it is more complicated to use. Now more and more people are using Jmeter for stress testing. It's free and very easy to use.

 

3. Steps to do a stress test

1. Write a script or record a script

2. Using user-defined parameters

3. Scene Design

4. Use a controller to control how many users to simulate

5. Use the listener to view the test results

 

4. Examples of stress testing in this article

        The following example is: Simulate 200 users with Jmeter on a computer, and at the same time request the service interface provided by my SpringMVC project to check whether the returned time is within the normal range.

1. Use CSV Data Set Config to parameterize

        First, we put the parameters needed for the test in the txt file, create a new localdata.txt file, and enter some data (there can also be two data in this line, separated by commas, and also set comma-separated in CSV Data Set Config ok).


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



2. Add HTTP Request

        We add http request, send get to http://localhost:8080/SpringMVC/greet?name=lisi

        Right-click on Thread Group (Add -> Sampler -> HTTP Request), and the data to be filled in is as follows:



3. Use Thread Group to control how many users to simulate

        Check Thread Group


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

        Ramp-Up Period (in seconds): Sets how long it takes for the threads to start all up. If the number of threads is 200 and the preparation time is 10, it will take 1 second to start 20 threads. That is, 20 threads are started every second.

        Loop Count: The number of times each thread sends a request. 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 "Forever" is checked, all threads will keep sending requests until you choose to stop running the script.

 

4. Add Summary Report to view test results

        Select Thread Group and right click (Add -> Listener -> Summary Report)

 

5. Run it

        So far, the script is all written, let's run it, how to see the test results



6. Download the source code

        Click the attachment "performanceTest.zip" to download the configuration file, and pay attention to modifying the path of localdata.txt.

 

Article source: http://www.cnblogs.com/TankXiao/p/4059378.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326828025&siteId=291194637
Recommended