JMeter implementing a simple Web load test

Source: Internet
Author: User

JMeter implementing a simple Web load test

Brief introduction

Apache JMeter is a Java -based stress testing tool developed by the Apache organization. For stress testing of software, it was originally designed for web application testing, but later extended to other test areas. It can be used to test static and dynamic resources such as static files, Java applets, CGI scripts , Java objects, databases, FTP servers, and so on.

Installation

The above text mentions that JMeter is developed based on Java, so theoretically we can run on any Java-installed platform, and the fact is, we'll talk about installation steps.

· Install the Java environment, this step we do not do too much explanation, whether it is Baidu, Google can search for a large number of devices to install Java technical articles.

· Download the source code, download the website

Open the website to the download page

· Extract

· Run

For Windows and Macs with a user interface, double-click the JMeter in the bin directory, and we'll talk about the server side without the user interface.

More detailed open way can see here

Use

We have now completed the installation of JMeter, and the following question is how to operate the

is the JMeter open interface.

· Add a test task

The main example of this article is a load test scenario that simulates a multi-GET request

The interface starts with a test plan added by default, and the following steps are also going to be built around this test plan.

· Add a thread group

In the thread group we want to define the amount of user access and frequency of access

Number of threads indicates how many users are simultaneously accessing the simulation

The access cycle represents the time interval for each set of out-of-box access

The number of cycles is the number of times that a thread group is to be cycled, optionally forever

Scheduler is in order to better control the time of testing in which we can better specify the test plan, the general scheduler and the number of cycles to choose one

· Add HTTP Request Content

Add the HTTP request content, is the real we want to define the domain name of the request, access to the content where the request is accessed.

Web Server A column we don't explain more, mainly the domain name of the request, IP plus port, in which we take a local running service for example

The HTTP request column is the content that defines the request, the path of the request, the content of the POST request, the uploaded file, and so on.

Here we want to simulate a GET request to test the server load balancing, to consider a variety of circumstances, we naturally have to separate the request interface to test, and can not be placed on a single interface hanging dead, so that the more realistic simulation of user requests, but also more realistic to detect the server load.

Here we are going to use a jmeter built-in function _stringfromfile

Of the four parameters, the first one is the file name, the second is the parameter to carry (temporarily unused), the third is the start line number, and the fourth is the end line number. Once completed, click Generate will output a string in the inside,

This is one of our sample files, each behavior one request, can be customized request parameters inside

We do not write at the end of the line, so we continue to loop execution after the two requests have been executed sequentially.

We have generated a function string, below we will just get the string, fill in the HTTP request path inside, a simple test plan is basically completed.

Test

We have completed the basic test plan, below we will start to test, if we are in the user interface, we need to see the test details, as well as the summary of what to do, on the previous thread group, add the table to view the results and aggregated report listener.

Click on the run above and we'll see the results in the above report in turn

In this way, our simple test is basically done.

Server -End Testing

Most of the time, we have low-profile interface configurations, so sometimes we need a strong server side to help with testing. Server-side installation, we will not say, and the interface is very similar to the installation of Java download program

Export the Jmx file of the test plan in the user interface and upload it to the server

Upload the file we generated the path to the server

Edit the Jmx file to replace the original URL file path with the file path on the server

Run

./jmeter-n-T. /.. /http request. Jmx-l. /.. /log

-n means no user interface

-T refers to the test file JMX

-L is the location of the log file that represents the detailed test request

When you finish running the above code, the following results appear

Because we casually point to a service, so err is 100%, please automatically ignore, so that everyone can complete the test on the server.

Ps

As the project grows and the single server is unable to complete the test task, we can use JMeter's multi-node mode to operate, allowing multiple machines to be tested at the same time. This one we also put it in later to explore.

JMeter implementing a simple Web load test

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.