Http_load principle Analysis of web pressure measuring tool

Source: Internet
Author: User

Http_load principle Analysis of web pressure measuring tool

First, preface

Http_load is an open source tool for testing Web server performance and can be downloaded to the latest version of Http_load from the following URLs:

http://www.acme.com/software/http_load/(the page is simply too shabby ...). )

Thankfully, the software has been kept up to date (unlike Webbench, which has been a relic of the past decade.) Webbench Source Code Analysis Please refer to: http://www.cnblogs.com/xuning/p/3888699.html), and the update frequency is quite high appearance. After I downloaded the August 2, 2014 version, and then the August 14 again, there was a new version. This article analyzes the HTTP load version is "Http_load 02aug2014", fortunately, the difference between each version is very small, this article is also a good commonality.

Ii. Methods of Use

After downloading and extracting, you can get the executable tool by going to the root directory of the tool and make it directly. Use the method as shown in the following:

The Url.txt content shown in the figure is a number of URL links, one per line, such as: http://127.0.0.1:80/index.html.

For more information, use the format:

./http_load [-checksum] [-throttle] [-proxy host:port] [-verbose] [timeout secs] [-sip Sip_file]

-parallel N | -rate N [-jitter]

-fetches N | -seconds N

Url_file

Options and Parameters:

-fetches: The total number of times to access the URL, regardless of the success of the failure is recorded as one time, the program exits after the number arrives.

-rate: The number of accesses per second (that is, the frequency of access) that controls the speed of the performance test.

-seconds: The time that the tool runs, the program exits after the time of the seconds setting is reached.

-parallel: The number of maximum concurrent accesses that control the speed of the performance test.

-verbose: With this option, the progress information for the current test is printed once every 60 seconds on the screen.

-jitter: This option must be used in conjunction with-rate, indicating that the actual frequency of access will fluctuate by 10% of the amplitude of the value set by the rate.

-checksum: Because you want to access a URL many times, in order to ensure that each access to receive the server back package content is the same, you can use the checksum check, inconsistency will be on the screen output error message.

-cipher: This parameter is used when using the SSL layer (the URL is the beginning of https) and a specific set of ciphers is used.

-timeout: Sets the time-out, in seconds, by default of 60 seconds. The connection is recorded as a timeout every more than once

-proxy: Set the Web Proxy in the format-proxy host:port

-throttle: Current limit mode, limit the amount of data received per second, unit bytes/sec. The default limit for this mode is 3360bytes/sec.

-SIP: Specifies a source IP file in which each line of the file is in the form of Ip+port.

It is important to note that the-parallel parameter and the-rate parameter must have one that specifies how the request package is sent;-fetches and-seconds two parameters must have one that specifies the termination criteria for the program.

Iii. comparison with the Webbench

Webbench is another Web performance testing tool, its source analysis can refer to the following connection:

Http://www.cnblogs.com/xuning/p/3888699.html

The Webbench uses a multi-process package, which supports up to 30,000 concurrent volumes, while the Http_load uses a single-process parallel reuse method for the packet. Because there is only one process, http_load for machine resource consumption, performance requirements are not high, but its disadvantage is that the maximum concurrency is much less than webbench, can only reach the magnitude of thousands. In many scenarios, thousands of of the magnitude is more than enough, so the use of specific tools depends on the actual situation.

We use Webbench and http_load to stress access to the same URL, with the following results.

[Email protected] ~/webbench-1.5]$./webbench-t --C +http//127.0.0.1:8080/user.pngWebbench-Simple Web Benchmark1.5Copyright (c) Radim Kolar1997-2004, GPL Open Source Software.Benchmarking:GET http://127.0.0.1:8080/user.png +Clients, running -sec. speed=180340Pages/min,5268934bytes/sec. Requests:90170Susceed,0failed. [[Email protected]~/http_load-02aug2014]$./http_load-parallel +-fetches90000Url.txt90000Fetches,830Max Parallel,1.2933e+08bytesinch 30.5439seconds1437Mean bytes/Connection2946.58Fetches/sec,4.23424e+06bytes/Secmsecs/connect:0.772754Mean215Max0.025Minmsecs/first-response:17.2259Mean288.007Max1.735minhttp Response Codes:code $–90000

If the conversion is done, Webbench measured the page rps is 180340 pages/min = 3006rps, which is very close to http_load test results 2946fetches/sec results, and http_load statistics more comprehensive, Data validation is also more complete. For traffic data per second, the result of Webbench is 5268934bytes/sec,http_load is 4234240bytes/sec. The difference is that http_load the head of the HTTP message when it was counted, and Webbench did not remove the head. Next, let's take a look at the http_load implementation principle.

Iv. Work Flow

The workflow of the program can be expressed in the following diagram, the main part of the execution process is within the cycle of the flowchart. Http_load is a single-process program, so all calls within the process are non-blocking, guaranteeing program smoothness. The process of executing the procedure body in a large cycle, the final condition of the determination and time-out determination. The time-management method is to use a zipped hash table, which runs the timeout handler when the timeout occurs.

Five, the principle analysis

5.1 Program execution Process parsing

If you use simplified code to describe the flowchart described in the previous section, you can refer to. The loop in the flowchart is also the for loop in the main function. There are 4 main things to do within the main loop. First, detects whether the current program satisfies the termination condition, or, if satisfied, calls the End function to exit the program, otherwise proceed to the next step. Then, with the Select Listener descriptor state, once a readable or writable descriptor appears, the Handle_connect and handle_read two functions are processed separately. It is to be recalled that the source program consumes a lot of code in order to eliminate the header of the HTTP request message in the process of reading the socket buffer. Then, the loop tail performs a time-out detection, checking that the current time has not exceeded every timestamp registered in the hash table, and if so, executes its corresponding timeout handler. The specific timestamp management method is shown below. There are 5 kinds of time stamps in the source code need to register, corresponding to 5 time-out processing functions, refer to the figure of the time-out processing function set.

5.2 Three important structural bodies

The most important structures in the three source codes are described in detail. First, the program takes a global variable connections array to control each TCP connection, and each element in the connections array is a pointer to the connection struct. The connection structure contains variables for recording test data, control variables for the connection state, and connection configuration information that was initially read from the file. The second structure is the URL structure, in http_load, the URL you want to request is stored in a file and can be larger than one. The information for these URLs is read into an array of URLs that consists of pointers to the URL structure body. Requests are randomly sent to these arrays. One advantage over Webbench,http_load is its data validation link. Each URL is provided with the checksum value of the return request, which verifies that the content returned by the same URL each time the request is consistent. The third structure is the time management method that makes up each node of a zipper hash table. It contains pointers to time-out handlers and variables that record time-outs.

5.3 Time Stamp Management method

The most ingenious of Http_load is its time management method. In this tool, there are a lot of places that need to be timed to trigger, such as outputting a test progress report at regular intervals; the link exceeds a certain time to be remembered as time-out, output time-out error message, set sending frequency, send a request every time, etc. These timestamps and their timeout-triggered functions are all registered in a hash table of the Zipper method, in the form of a timer structure. Each linked list is sorted from morning to night in timestamp order. In this way, we can easily determine whether the current time has exceeded the time stamp in each for loop execution time-out detection, and if so, execute the timeout handler. At the same time, this data structure also improves the efficiency of inserting new timestamps.

Vi. Conclusion

Http_load and Webbench are very common pressure measurement tools, if used together, the results are compared, both to test the results of the calibration, but also to help familiarize the pros and cons of the two tools. Http_load's design ideas can also be used in business testing tools to help develop more efficient pressure-measuring tools.

Http_load principle Analysis of web pressure measuring 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.