How to Use jmeter for stress testing --- conversion

Source: Internet
Author: User
Tags http cookie

Jmeter is a performance testing tool. Similar to LoadRunner, jmeter has many functions. Our common function is to use jmeter to simulate multiple browsers to perform stress tests on websites.
Download jmeter address: http://jakarta.apache.org/
For a general website, you must log on to the business function before accessing the business function. The following describes how to use jmeter to log on to the system and perform stress tests on the main business.
1. Run jmeter.
2. The left Tree shows the test plan and workbench nodes.
3. Select the test plan and right-click "-" Add-"threads (users) thread group.
The number of concurrent threads in a thread group can be set for stress testing.
The "number of cycles" setting is not always selected, and the number of cycles is set to 1.
4. Now we will introduce how to set a logon HTTP request, select a thread group, and right-click "add" "sampler-" and "http request.
HTTP requests mimic browser access.
In "server name or IP", set 127.0.0.1, port number: 8080, "method" to set post, and path to set the website logon address, such as "/exam/operatoraction ".
The user and password are required for logon. Add parameters in the "send parameters together with request" list. The parameter value is set based on the Web application. For example, login_user = 0001; login_password = 1; actflag = Login
5. After Successful Logon, the website usually jumps to the home page. In jmap, you can determine whether to log on to the home page as expected (this step is optional ). Select "http request" in Step 4, right-click it, and choose "add"> "assertions"> "respond to assertions. Set "apply to" to main smaple only; "response field to test" to set "url sample"; "pattern matching rule" to "include ", "mode to be tested" adds the page to jump to the main page, for example, "studentmain. JSP"
6. After a website is logged on, a session is generated in Tomcat, and you do not need to log on again when accessing other pages, provided that the browser supports cookies. In jmap, the following key settings are also required to continue accessing other pages.
Choose "thread group"> "right-click"> "add"> "Configuration component"> "HTTP cookie manager. After this step is added, the HTTP request will have the cookie function, that is, after the login is successful, access to other pages will not jump to the login page to log on again.
7. Perform repeated stress tests on the target page.
7.1 how to enable repeated access to the page under test to achieve the pressure measurement effect. Choose "thread group"> "right-click" logical controller ">" loop controller. Select "forever" in the number of cycles ".
7.2 select the just-added "loop controller", right-click "add"> "sampler-" HTTP request, and set the IP address and port in step 4, the HTTP Request Method is "get" and the path is the URL of the stress test, for example, "Exam/Business/studentexam. action. studentexamaction? Action = gow.mockexam ".
According to the above settings, the configuration has been completed and can be used for stress testing. You only need to click "run" to start the stress test.
8 jmeter provides many tools to view pressure results. It is a good analysis tool for stress testing. You can add the following tools.
8.1 view the result tree. It records the data sent and returned for each request. Choose "thread group"> "right-click"> "add" to view the result tree.
8.2 view the results in a table. You can view the response time of each request. Select "thread group"> "right-click"> "add"> "view results in a table.
8.3 Summary Report. You can view the average response time and maximum response time.

 

 

As a pure Java GUI application, jmeter consumes an astonishing amount of CPU and memory, so when thousands of concurrent users need to be simulated, using a single machine to simulate all concurrent users is insufficient, and may even cause Java memory overflow errors. However, jmeter can also use multiple machines to run the so-called agent like LoadRunner to share the load generator pressure and obtain a larger number of concurrent users. According to the official jmeter document, you need to complete this configuration by yourself, but don't worry, it will be very simple ^_^

1. Install jmeter on all machines that want to run jmeter as the load generator, and determine one of them as the controller and the other as the agent. Then run the JMeter-server.bat file on all the agent machines -- assuming we use two machines 192.168.0.1 and 192.168.0.2 as the agent;

2. Find the bin directory under the jmeter installation directory of the controller machine, find the jmeter. properties file, and open it using notepad or other text editing tools;

3. Search for the "remote_hosts =" string in the opened file. You can find this line "remote_hosts = 127.0.0.1 ". 127. 0 .. 0.1 indicates the machine on which the jmeter agent is running. You need to change it to "remote_hosts = 192.168.0.1: 1664,192.168 .0.2: 1664" -- 1664 indicates the default RMI port number for communication between the Controller and agent of jmeter;

4. Save the file, restart jmeter. bat on the Controller machine, and enter the Run-> Remote Start Menu. What did you see? Pai_^

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.