"Turn" jmeter practice

Source: Internet
Author: User

Directory (?) [-]

    1. Introduction to JMeter Related concepts
    2. Application examples
    3. Abapachebench Contrast

This paper mainly introduces the usage of common tools jmeter in performance testing, so as to make it easy for the developers to self-test the system and simulate the user operation access request. Finally, a simple comparison is made with the pressure measurement tool ab under Linux.

1. Introduction to JMeter Related concepts:

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.
JMeter Each task consists of a test plan, each with a variety of elements, and a combination of different elements to complete the test plan. Common elements are as follows:

Thread Group: Contains a set of threads that each thread executes independently of the test plan.

Sampler: Sampler With several different sample implementations to initiate various requests, such as HTTP requests, JDBC requests, javatest requests, and so on.

Logic controller: There are many different implementations of logical controllers that determine the order in which each sample executes.

Listener: There are a number of different implementations, mainly for statistical testing of data in the operation of the session and display, such as a graphical way to display response time.

Timer: Timer, there are a number of different implementations, can be used as each request to see the pause time.

Assertions: Asserts that there are many different implementations that can test if the content returned after the sample request meets the expected value. For example, you can determine whether the content returned by HTML meets expectations.

Configuration elements: Configures the element to be used primarily as a parameter to the request of sample.

Because each controller can be nested with each other, and has scopes (such as configuration elements that take effect only in a recently nested controller), different test plans can be assembled by the combination of these elements.

2. Application Examples:

A) Scene One: Multi-user concurrent number pressure measurement system.

In this scenario, 100 users are accessing the system concurrently, and each user loops 10 times to access the system.

Start by creating a new test plan in JMeter and then create the individual elements as shown. (next to the icons are named for each elements instance)

Next, the configuration of each element is set:

I. 100 Concurrency: This is a thread group that is configured as follows:

In this example set 100 threads to test, Rampupperiod is in the number of seconds to evenly start the thread to complete, set 0 is the simultaneous start, the number of cycles is 1.

II. Loop controller: This is a loop-type logical controller that sets the behavior within its scope to loop 10 times-each thread will cycle through 10 HTTP requests. The loop controller is configured as follows:

Iii. HTTP Request: This is a sampler, the most important part of the test, responsible for initiating an HTTP request. In this HTTP sampler, you can set: server address, access path, access parameters, request method (GET/POST/ETC). ) and other properties. Because the sampler is nested within the loop controller, it will loop 10 times to initiate the request. Some of the configurations are as follows:

Figure1 HTTP Sampler Configuration

Iv. Response Assertion: This is a response assertion that can set the response condition and then return success or failure if the assertion is satisfied, and the value can be used for subsequent statistical results. The configuration is as follows (the success in this example is the response data result returned by HTTP, so the assertion is true as long as the success is included):

Figure2 Assertion Configuration

V. HTTP request parameter settings: This is used in conjunction with Httpsampler, just to write the content that needs to be frequently configured here, configure the way and HTTP sampler similar. Its parameters take effect in the most recent nested controller.

Vi. Summery report: This is a listener, which counts the requests initiated by sampler in the test plan, and can be counted as part of the success of the assertion. The effect is as follows:

Figure3 Summery Report

Because this example has only 1 HTTP sampler, the first line of the result is the statistical result of the sampler.

Samples indicates that there are 1000 requests initiated, average is the average response time (MS), throughput is the throughput, the rest of the parameters words too literally basic can be understood, specific to the JMeter reference manual.

Vii. Graphical results: This is another listener, it is the statistical results of the icon display, and Summerreport is independent of another statistic, the effect is as follows:

Figure4 Graphical Results Report

Legend parameters are basically consistent with the data in Summeryreport

The test plan is then configured, and then the test plan is started.

Click on the toolbar or the menu bar to run > start, the test plan to start execution. Once the execution is complete, you will see the Figure3,figure4 icon result.

As you can see from the results, this test initiates a total of 1000 HTTP requests, the average time per request is 24 milliseconds, and the throughput is 318.1/sec

b) Scenario two: Multi-user Login multi-step access system.

In this scenario, 2 users log on to the system first, then quiesce for 1 seconds, and then visit 2 pages in turn.

Follow the steps above to configure the test plan first:

FIGURE5 Test Plan 2

In this test plan, there are 2 thread groups A and B, each thread group represents 1 users, each user first in the Knowledge Base landing page, and then jump to the member center, and finally access the machine list.

This test plan introduces the cookie manager, which can save the user's cookie to the thread after logging in. Also in the cookie Manager you can set a different cookie.

It also introduces a one-time controller, which guarantees that the thread will log on only once in multiple cycles.

In addition, login fragment and page access fragment are 2 separate modules that can be referenced by 2 thread groups for reuse purposes without having to set up requests for 2 thread groups individually.

Specific details can be found in the JMeter test plan file of the attachment.

With the basic elements above, you can perform basic access behavior simulations and concurrency tests for your app. The staff was very friendly and helpful.

3. Ab (apachebench) comparison

AB is another test tool under Apache. What is the relationship between the concurrency results of AB pressure measurement and the JMeter test results, which we can compare. In the following example, a simple servlet is run on a Tomcat server, and the servlet simply sleeps for 100 milliseconds and then returns success to response.

The test results for JMeter and AB are shown in the following table:

Comparison of Figure6 JMeter and AB for concurrent pressure measurement

One of the red is that there was an error, and the result was less stable and did not continue to press down again.

As you can see, the AVG of JMeter (average response time per thread) and AB for the Times per request,throughput with request per second are basically the same when the number of threads is below 100, but then the difference is quite large. The specific reason is not clear, perhaps JMeter has more things to deal with and based on the GUI's sake, people who have the knowledge please advise. However, if the number of cycles per thread is set to an unlimited time, the performance of the data display will increase jmeter.

To sum up, we generally say that the Qps,tps, corresponding to JMeter should be throughout, corresponding to AB should be requestper second, combined with 2, you can roughly calculate the throughput of the application probably in which range. In this case, it should be around 1200~1400.

Finally, a summary of the next.

This article mainly describes the basic use of jmeter, and combined with 2 scenarios to explain how to configure the test plan, for the development of the use of the introduction. Finally, a demo application is compared with the results of JMeter and AB under pressure measurement. Finally, we will use the next StackOverflow to introduce the two scenarios:

JMeter tells you how long each request actually takes. AB is simply a mathematical way to statistically average. So from the accuracy, JMeter is more accurate than AB, more like data processing. But AB's speed is faster and lighter. JMeter is better if the purpose of the performance test is to have a more realistic performance of the application being measured. However, if you are only using the fewest machine resources to generate the most access requests, that AB is suitable ...

Resources:

JMeter Manual. PDF (Chinese official document)

JMeter official website (http://jmeter.apache.org/)

Cnblogs Blog: Jackei (Http://blog.csdn.net/jackei)

JMeter Application Guide. pdf

"Turn" jmeter practice

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.