Apache Jmeter (1)

Source: Internet
Author: User
Tags http post

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. JMeter can be used to simulate huge loads on servers, networks, or objects to test their strength and analyze overall performance under different pressure categories. In addition, JMeter is able to perform functional/regression testing of the application by creating a script with assertions to verify that your program returns the results you expect. For maximum flexibility, JMeter allows you to create assertions using regular expressions.

1. Download JMeter

Official website Download latest version: HTTP://JMETER.APACHE.ORG/DOWNLOAD_JMETER.CGI, currently the latest version of Apache JMeter 2.9
Using JMeter dependent JDK, it is recommended to install JDK version 1.6
Installing JDK under Linux Reference article: http://www.linuxeye.com/Linux/Linux-install-JDK.html
Windowns installation JDK is similar to Linux under installation, this is not described here.

2. Start JMeter

Here is under win, the graphical interface is more convenient
Under directory Apache-jmeter-2.9\bin you can see a jmeter.bat file, double-click the file, and see the JMeter Control Panel.

3. Run pre-preparation

Now to stress test the linuxeye, the pressure test object is a random number of web links, these links are written in a text file, in the stress test will be randomly read.
1) Set up a thread group, such as

Why set up thread groups? The reason is simple because we want to simulate multiple threads (users) to access Linuxeye.
In the Thread Properties section, the number of threads is how many threads are started, and what I'm filling out here is 10,ramp-up Period (in seconds), which indicates how much time between threads is allowed, in seconds, for example, if you fill in 10, then 10/10=1 indicates that 10 threads are requesting a Web site every 1 seconds.
Number of cycles: 60 threads run Complete is one time, the number of cycles is such a request process how many times, I am here to fill out the test is 2.
Do not forget to save once you have modified one setting.

2) Set up the request server, pressure link and other information
The next thing is, naturally, what is the address of the website we're testing? What is a link? So now we're going to set up this information.
Right click on the thread group we just created, in the popup menu, choose Add->sampler->http request, popup like interface:

Path:
If you are just a stress test on a link, just fill in a link to OK, such as HTTP// Www.linuxeye.com, but in most cases this is not the case, we need multiple links here, as we have just started, we want to save multiple links to a text file, and then randomly read the stress test. We can do this,

Select _stringfromfile in the Select a feature drop-down list, and then create a new test file on this machine C:\Users\root\Desktop\apache-jmeter-2.9\ Test.txt, fill in the path to the test file in the first line (you can also not be in the first row), such as:

Then click on the "Generate" button and a string will be generated in the left text box of the Generate button, such as:
${__stringfromfile (C:\Users\root\Desktop\apache-jmeter-2.9\test.txt,,,)}
In the Test.txt test file, we write a URL link for each line, in the following format:

/command/linuxrumen/program/jianzhan/command/cat.  HTML/command/chmod.  HTML/command/lsattr.  HTML                   

Note that there is no HTTP/A in front of each line Www.linuxeye.com such information, because we have already filled in the server address is www.linuxeye.com, here there is no need to fill in the same prefix for each URL, and the above URL format is just an example, representing the part after the domain name.

This way, when we are not requesting it, we randomly select URLs from Test.txt for stress testing.
Another notable place is that if the parameters in the case of Chinese, the runtime may be garbled, this time you need to note that your encoding settings in the JMeter and the page encoding you want to request is consistent.

The options below the path text box can be made by default, and use Multipart/form-data for HTTP post is the case when there are attachments in the request, which is not normally checked.

3) View running results
Right-click on the thread group, and in the pop-up menu, choose Add-and-listener, using the table query results, such as:

4. Running

Of course, before running, please save all the changes.
The results table after the run is as follows:

The properties are as follows:
Sample: Ordinal of each request
Start time: The start of each request
Thread Name: Name of each thread
Label:http Request Name
Sample time: Per request, in milliseconds
Status: The request state, if the tick indicates success, if the fork represents a failure.
Bytes: Number of bytes requested
If the status is a fork, it is clear that the request is a failure, but if it is a tick, it is not considered that the request must be completely successful, because it depends on whether the number of bytes in the bytes is the normal size of the requested Web page, or if it does not indicate a packet loss, is not completely successful.

Here are a few more parameters:
Number of samples: that is, the number of requests mentioned above, the success of the case equals the number of concurrent numbers you set multiplied by the number of cycles.
Average: Average time requested by each thread
Latest Sample: Indicates when the server responded to the last request
Deviations: Server response time changes, the size of discrete measurements, or, in other words, the distribution of data (which I don't quite understand).

Terms:
1. Thread Group: Each task in the test has to be processed by the thread, and all of our later tasks must be created underneath the thread group. You can build it with the Add->threads (Users), thread group, in the Test Plan (right-click), and then there are several input fields in the Thread Group panel: Number of threads, ramp-up Period (in seconds), number of loops, where Ramp-up Period (in seconds) indicates that all threads are created within this time. If there are 8 threads, ramp-up = 200 seconds, then the thread has a start interval of 200/8=25 seconds, and the benefit is that the server will not have too much load at first.
2, Sampler (Sampler): You can think that all test tasks are taken by the sampler, there are many kinds, such as: HTTP request.
3. Assertion: The result of the request returned by the sampler is correct.
4, Monitor: Its function is to the sampler request results display, statistics some data (throughput, kb/s ... ) and other

Apache Jmeter (1)

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.