Jmeter: graphic interface stress testing tool

Source: Internet
Author: User

Jmeter is a powerful graphic interface stress testing tool. It is fully written in Java. There are many articles on the Internet about jmeter. I didn't want to write similar articles again, however, I found that some of the most critical settings and operations we will use in our tests are rarely written clearly. For example, there is a common problem: how do I perform stress tests on multiple links of a website? Generally, we do not need to test a link. If we test a website, these links are usually written to a text file, during the test, the link in the file is Randomly Read for stress testing. We are familiar with some stress testing tools, such as siege.

When I used jmeter, I found that my colleagues who used jmeter before, but even so, they are not clear about how to write multiple links to text files and perform random read stress tests. Therefore, I plan to write such an article when I am free to facilitate users.

I,Official Website

Http://jakarta.apache.org/jmeter/

II,Run

Download and unzip, under the directory jakarta-jmeter-2.4 \ bin can see a jmeter. BAT file, double-click this file, open the initial interface such:

Note that the above displays Chinese characters. If you want to use other languages, such as English, you can use the menu options-> Select language-> English. Of course, the same operation is performed if you want to convert them to Chinese.

III,Run preparations

We now want to conduct a stress test on the Child monkey Boke. The stress test object is a random number of webpage links, which are written in a text file and will be randomly read during the stress test.

1. Create a thread group, such

Why do we need to establish a thread group? The reason is simple, because we need to simulate multiple threads (users) to access the website.

The thread Group Creation Interface is as follows:

 

You can enter the name as needed. By default, "continue" is selected.

In the thread attribute section, the number of threads is the number of threads started. Here I fill in 60. ramp-up period (in seconds) indicates the interval between threads. The unit is seconds, for example, if 120 is entered, 120/60 = 2 indicates that the website is requested every two seconds between 60 threads.

Number of cycles: 60 threads are run once, and the number of cycles is the number of times that such a request process runs. Here I fill in 1000.

After each modification, do not forget to save it.

2. Set Request server, pressure link, and other information

Next, we naturally want to test the website address? What is the link? So now let's set this information.

Right-click the created thread group and choose add> sampler> HTTP request from the shortcut menu. The page is displayed, as shown in:

Name: Enter at will

Note: Optional

Server name or IP Address: Enter zihou. me here

Port: Enter 80 here.

The timesout part can be left empty.

HTTP request part of the Protocol: HTTP, method I chose get, Content Encoding I filled in UTF-8.

Path:

Here it is worth mentioning that this path, if you just to a link for stress testing, then here is very simple, you just fill in a link is enough, such as http://www.zihou.me, but in many cases, this is not the case. We need multiple links here. As we mentioned at the beginning, we need to save multiple links to a text file, then, random reading is performed for stress testing. We can do this,

 

Open the interface, for example:

Select _stringfromfilefrom a function drop-down list. Then, create a test file text.txt on the local machine and enter the path of the test file in the value of the first line (you can also leave the first line), for example:

Click "generate". A string is generated in the left text box of the generate button, for example:

$ {__ Stringfromfile (E: \ test \ test.txt ,,,)}

In the test file, we write a URL link per line in the following format:

2011/03/26/3054

2011/03/26/3052

2011/03/26/3042

2011/03/25/3040

2011/03/25/3034

2011/03/24/3027

Note that there is no such information as http://www.zihou.me in front of each line, because we have already filled in the server address zihou in front. me, there is no need to fill in the same prefix for each URL here; in addition, the above URL format is just an example, indicating the part after the domain name, but many times the URL is followed by parameters, such as http://www.zihou.me/P? A = 1 & B = 3. In this case, the above link can be written:

A = 1 & B = 3.

Now we can enter the preceding path as follows:

/$ {__ Stringfromfile (E: \ test \ test.txt ,,,)}

In this case, when we are not requesting a request, we will randomly select a URL from test.txt for stress testing.

In addition, if the parameter contains Chinese characters, garbled characters may occur during running, at this time, you must note that the encoding settings in jmeter are consistent with the webpage encoding you want to request.

The options under the path text box can be set by default. Use multipart/form-data for http post is used when there is an attachment in the request. Generally, this option is not selected.

Send parameters together with the request:

If you only perform stress tests on a fixed page, you don't need to set the URL in the text file as mentioned above. Just set it here, here, the name is the parameter name, and the value is the parameter value. It is OK to add it here, but if you are using multiple links under pressure, you do not need to fill in here.

3. View running results

After the above settings, I naturally thought about how to view the running results? In this regard, jmeter provides some viewing methods, such as table form and curve form. I personally think it is enough to view the form!

Right-click the thread group and choose add> listener> query result in table from the shortcut menu, for example:

The pop-up interface is shown in the following figure:

 

Of course, you can also select other viewing methods. You can also see that there are many ways in the listener menu.

IV,Run

Now we can run it!

Choose "run"> "start" from the menu, for example:

Of course, you have to save all the modifications before running.

The result table after running is as follows:

The attributes are as follows:

Sample: the serial number of each request

Start Time: Start time of each request

Thread name: name of each thread

Sample Time: the time taken by each request, in milliseconds

Status: Request status. If it is a checkmark, the request is successful. If it is a cross, the request fails.

Bytes: number of bytes requested

If the status is a cross, it is obvious that the request has failed, but if it is checked, it cannot be considered that the request must be completely successful, because we have to check whether the bytes are the normal size value of the requested webpage. If not, it indicates that packet loss occurs, and it is not completely successful.

There are several parameters below

Sample Number: the number of requests mentioned above. If the request is successful, the number of concurrent requests is multiplied by the number of cycles.

Average: average request time of each thread

Latest sample: the time when the server responds to the last request.

Deviation: the size of the server response time change, discrete value, or, in other words, the data distribution (which I don't quite understand ).

In the preceding parameters, I personally think that only the status and bytes parameters are enough.

Well, the main introduction is so much. In fact, the scope of jmeter's stress testing is far beyond that of the web. It can also be used for Java small service programs, CGI scripts, Java objects, and databases, FTP servers, etc. More use can be studied and mastered according to your own needs.

Finally, you must note that both HTTP request and result view are created under the thread group node. In fact, you do not have to create a thread group. You can also create a thread group under the test plan. However, creating a thread group makes the test intent clear at a glance, that is, our HTTP request and result view are based on our set thread group.

Jmeter: graphic interface stress testing tool

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.