Three stress testing tools: http_load, Apache AB, and siege

Source: Internet
Author: User
Tags install openssl response code
Document directory
  • Average visits per second
  • Test whether the website can withstand the expected access pressure

Download http_load from http://www.acme.com/software/http_load/
, Installation is also very simple, just make; Make instlall.

Http_load
Two examples of the standard are:

  1. Http_load-parallel 5-fetches 1000 urls.txt
  2. Http_load-rate 2-seconds 300 urls.txt

 

The example is just a reference. The parameters can be freely combined, and there is no limit to the selection between parameters. For example, if you write http_load
-Parallel 5-seconds 300 urls.txt
Also
Yes. We will briefly describe the parameters.
-Parallel
Shorthand
-P
:
Meaning concurrent use
Number of processes.

-Fetches
Shorthand
-F
:
Meaning total access
Question count

-Rate
Shorthand
-P
:
Meaning access per second
Frequency

-Seconds
Shorthand
-S
:
Meaning total access
Time


Urls.txt is a URL list with a single line for each URL. Of course, you can also directly follow a URL instead of a URL list file.
Instance:
  1. Http_load-rate 5-seconds 10 URLs
  2. 49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds
  3. 5916 mean Bytes/connection
  4. 4.89274 fetches/sec, 28945.5 Bytes/sec
  5. Msecs/Connect: 28.8932 mean, 44.243 Max, 24.488 min
  6. Msecs/first-response: 63.5362 mean, 81.624 Max, 57.803 min
  7. HTTP Response codes:
  8. Code 200 -- 49

 
Analysis:
1.49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds
In the preceding test, 49 requests are run, the maximum number of concurrent processes is 2, the total data transmitted is 289884 bytes, and the running time is 10.0148 seconds.

2.5916 mean Bytes/connection
The average data volume transmitted per connection is 289884/49 = 5916.

3.4.89274 fetches/sec, 28945.5 Bytes/sec
The number of response requests per second is 4.89274, and the amount of data transmitted per second is 28945.5 Bytes/sec.

4. msecs/Connect: 28.8932 mean, 44.243 Max, 24.488 min
The average response time for each connection is 28.8932 msecs, the maximum response time is 44.243 msecs, and the minimum response time is 24.488 msecs.

5. msecs/first-response: 63.5362 mean, 81.624 Max, 57.803 min

6. HTTP Response codes: Code 200 -- 49
Indicates the type of the response page to be opened. If there are too many 403 types, you may need to check whether the system has encountered a bottleneck.
Special note: Here, we generally pay attention to the following indicators: fetches/sec, msecs/connect
Their common performance indicator parameters qpt-response users per second and response
Time, the time each connection returns to the user. The test results mainly refer to these two values. Of course, only these two indicators can not complete the performance analysis, we also need to divide the CPU and men of the server
Analysis to draw a conclusion

 

Sample run:



% ./http_load -rate 5 -seconds 10 urls

49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds

5916 mean bytes/connection

4.89274 fetches/sec, 28945.5 bytes/sec

msecs/connect: 28.8932 mean, 44.243 max, 24.488 min

msecs/first-response: 63.5362 mean, 81.624 max, 57.803 min

HTTP response codes:

code 200 -- 49


4.89274 fetches/sec. This value means that the server can respond to about 4.8 queries per second.
This value is based on 49 fetches/
Calculated in seconds of 10.0148 seconds

Average visits per second

http_load -parallel 5 -fetches 1000 urls.txt

This command line uses 5 steps at the same time and randomly uploads the URL list in urls.txt, with a total of 1000 accesses. Result After running:

1000 fetches, 5 Max parallel, 6e + 06 bytes, in 58.1026 seconds
6000 mean Bytes/connection
17.2109 fetches/sec
, 103266 Bytes/sec
Msecs/Connect: 0.403263 mean, 68.603 Max, 0.194 min
Msecs/first-response: 284.133 mean, 5410.13 Max, 55.735 min
HTTP Response codes:
Code 200-1000

From the above running results, the target website is only able to withstand 17 visits per second, not strong enough.

 

Test whether the website can withstand the expected access pressure

http_load -rate 2 -seconds 300 urls.txt

The target URL is frequently accessed within 300 seconds.


For example
If you need to test https, you must
# Configure: If you want to compile in
Support for HTTPS, uncomment these
# Definitions. You will need
Have already built OpenSSL, available
# Http://www.openssl.org/
Make sure the ssl_tree definition points to
# Tree with your
OpenSSL installation-depending on how you installed it,
# It may be
In/usr/local instead of/usr/local/SSL.
Ssl_tree =/usr

Ssl_defs =-duse_ssl
Ssl_inc
=-I $ (ssl_tree)/include
Ssl_libs =-L $ (ssl_tree)/lib-lssl
-Lcrypto

To use OpenSSL, you must install OpenSSL and the corresponding development environment.

Apt-Get install
OpenSSL
Apt-Get install libssl-Dev

Find-name SSL. h
/Usr
/Include/OpenSSL/SSL. h

Institute
The above red font must be modified.

Http_load FAQ

 

I usually share some of the summaries during the http_load process. You can add them together;

1. Prompt: Bytes Count wrong
If the page data obtained by httpd_load is inconsistent with the previous one, the error "byte count wrong" is returned.
This error can be ignored if it is a dynamic page;

2. Error: Too program open files
The open files restricted by the system are too small. You can modify the value of open files by using ulimit-n;

3. Unable to send large requests (request length> 600 characters)
The size of the Buf that receives the request is http_load.c by default.

912 static void
913 handle_connect (INT cnum, struct timeval * nowp, int double_check)
914 {
915 int url_num;
916 char Buf [600]; // modify as needed, for example, char Buf [4096]
917 int bytes, R;

Re-compile to get a large request that can be sent

4. cannot assign requested address
The client frequently connects to the server. Because each connection ends in a short period of time, a lot of time_wait operations are caused, so that the available port number is used up, so the new connection cannot bind the port.
To modify the configuration of the client machine,
Add the following to sysctl. conf:

Net. ipv4.tcp _ tw_reuse = 1 indicates enabling reuse. Allow time-Wait
Sockets is used again for New TCP connections. The default value is 0, indicating that the connection is closed;
Net. ipv4.tcp _ timestamps = 1 Enable TCP timestamp support. If this parameter is set to 0, the following settings
Does not work
Net. ipv4.tcp _ tw_recycle = 1 indicates enabling fast time-Wait sockets recovery in TCP connections

 

 

 

Apache AB stress testing




I used to install Apache without knowing how to test Apache performance. Now I have found a test tool. Is the test tool AB (Apache
Benchmark). In the Apache bin directory.

Format:./AB [Options]
[Http: //] hostname [: Port]/path
Parameters:
-N requests Number
Requests to perform
// The number of requests executed in the test session. By default, only
One row request

-C concurrency number of multiple requests to make

// The number of requests generated at a time. The default value is one at a time.

-T
Timelimit seconds to max. Wait for responses
// The maximum number of seconds for testing. The internal implicit value is-n.
50000. It limits the server test to a fixed total time. By default, there is no time limit.

-P postfile
File containing data to post
// Contains the number of post requests.
Data file.

-T Content-Type Header for posting

// The Content-Type Header used by the post data.

-V
Verbosity how much troubleshooting info to print
// Set the details of the display information-4 or a greater value will display the header information, 3 or a greater value can display the response code (404,200, etc ),
2 or a greater value can display warnings and other information. -V displays the version number and exits.

-W print out
Results In HTML tables

// Output results in HTML table format. By default, it is a table of the width of the two columns of the white background.

-I use
Head instead of get
// Execute the head request instead of get.


-X attributes string to insert as table attributes
//

-Y attributes string to insert As tr attributes
//
-Z
Attributes string to insert as TD or th attributes
//
-C
Attribute add cookie, eg. 'apache = 1234. (repeatable)
//-C cookie-name = value attaches a cookie to the request: Row.
The typical form is a parameter pair of name = value. This parameter can be repeated.

-H attribute add
Arbitrary header line, eg. 'Accept-encoding: gzip'

Inserted after all normal header lines. (repeatable)
-
Attribute add basic WWW authentication, the attributes

Are a colon separated username and password.
-P attribute add
Basic proxy authentication, the attributes
Are
Colon separated username and password.
//-P
Proxy-auth-UserName: Password
Provides basic authentication trust for a transit proxy. The user name and password are separated by one and sent in base64 encoding format. Whether or not the server needs,
Whether the 401 authentication request code is sent), this string will be sent.

-X Proxy: Port proxyserver and
Port Number to use
-V print version number and exit

-K use HTTP keepalive feature
-D do
Not show percentiles served table.
-S do not show
Confidence estimators and warnings.
-G filename output
Collected data to gnuplot format file.
-E filename output CSV
File with percentages served
-H display usage
Information (this message)
//-Attributes: Specifies the attribute string.
The defect program has various static declared fixed-length buffers. In addition, parsing command line parameters, server response headers, and other external inputs is also simple, which may have adverse consequences. It is not fully implemented
HTTP/1.x; only accept certain 'preview' response formats. Frequent use of strstr (3) may cause performance problems, that is, you may be testing the performance of AB rather than the server.

There are many parameters. Generally we can use the-C and-N parameters. For example:

./AB-C 1000-N 1000 http: // 127.0.0.1/index. php

This indicates that 1000 requests are processed simultaneously and the index. php file is run 1000 times.
#/Usr/local/Xiaobai/apache2054/bin/AB
-C 1000-N 1000 http: // 127.0.0.1/index.html. zh-cn.gb2312


This
Is apachetings, version 2.0.41-dev <$ revision: 1.121.2.12 $>
Apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/


Copyright
(C) 1998-2002 the Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (Be patient)
Completed100 requests
Completed
200 requests
Completed300 requests
Completed400 requests
Completed
500 requests
Completed600 requests
Completed700 requests
Completed
800 requests
Completed900 requests
Finished 1000 requests

Server Software: Apache/2.0.54
//
Platform apache version 2.0.54

Server Hostname: 127.0.0.1
// Server host name

Server port: 80
// Server port

Document path:/index.html. zh-cn.gb2312
// Document of the test page

Document length: 1018 bytes
// Document size

Concurrency level: 1000
// Concurrency

Time
Taken for tests: 8.188731 seconds
// The duration of the entire Test
Room

Complete requests: 1000
// Complete
Quantity

Failed requests: 0
// Failed requests
Quantity

Write errors: 0

Total transferred:
1361581 bytes
// Network transmission volume in the entire scenario

Html
Transferred: 1055666 bytes
// HTML content in the entire scenario
Transmission volume

Requests per secondd: 122.12 [#/sec] (mean)
// One of the most important indicators is equivalent
LR
In

Transactions per second


, In brackets
Mean
This is an average value.


Time
Per request: 8188.731 [MS] (mean)
// The second indicator that everyone cares most about is equivalent
LR
In

Average Transaction Response Time


, In brackets
Mean
This is an average value.


Time per request:
8.189 [MS] (mean, internal SS all concurrent requests)
// Average actual running time of each request

Transfer Rate:
162.30 [Kbytes/sec] committed ed
// The average network traffic per second can help eliminate the problem of excessive network traffic resulting in prolonged Response Time

Connection times (MS)
Min mean [+/-SD] median Max
Connect:
4 646 1078.7 89 3291
Processing: 165 992 493.1 938
4712
Waiting: 118 934 480.6 882
Total: 813
1638 1338.9 1093 7785
// Decomposition of the time consumed on the network. The specific algorithms of various data are not very clear.

Percentage of the requests served within a certain time (MS)
50%
1093
66% 1247
75% 1373
80% 1493
90% 4061
95%
4398
98% 5608
99% 7368
100% 7785 (longest request)
// Response of all requests in the entire scenario. In the scenario, each request has a response time, of which 50% of the user response time is less than 1093.
Millisecond, 60% of the user response time is less than 1247 milliseconds, and the maximum response time is less than 7785 milliseconds


For concurrent requests, the CPU is not actually processed at the same time, but rotated one by one according to the time slice obtained by each request. Therefore, the first time per
Request time equals to the second time per request time multiplied by the number of concurrent requests

 

 

 

3. siege1), Introduction
An open-source stress testing tool that allows you to perform concurrent access to multiple users on a Web Site Based on Configurations and record all requests of each user.
 
The corresponding time of the process, and repeated in a certain number of concurrent access.

2) Obtain

Http://www.joedog.org/

3) Installation
[Root @ localhost software] #
Tar-zxvf siege-2.69.tar.gz # Extract
[Root @ localhost software] # cd
Siege-1, 2.69
[Root @ localhost siege-2.69] #./configure
-- Prefix =/usr/local/siege # configure the installation directory
[Root @ localhost siege-2.69] #
Make & make install # compile and install

Note: An error is prompted during installation,

Make [3]: Entering directory '/usr/local/software/siege-2.69/doc'

/Usr/bin/install: cannot create regular file
'/Usr/local/siege/etc/siegerc': no such file or
Directory

Make [3]: *** [install-Exec-Hook] Error 1
Make [3]: leaving
Directory '/usr/local/software/siege-2.69/doc'
Make [2]: ***
[Install-Exec-am] Error 2
Make [2]: Leaving directory
'/Usr/local/software/siege-2.69/doc'
Make [1]: *** [install-am]
Error 2
Make [1]: Leaving directory
'/Usr/local/software/siege-2.69/doc'
Make :***
[Install-recursive] Error 1
Solution: mkdir-P
/Usr/local/siege/etc/siegerc to create such a directory, you can continue to install it.


4 ),
Command Format: siege-C concurrency-r repeat times-F urllist File
Urllist format:

Http://www.taoav.com

Http://www.tuhaoduo.com

Http://www.tiaonv.com

Result description:
Lifting the server siege...
Done.
Transactions: 3419263 hits // 419263 processed

Availability: 100.00% // 100.00% success rate
Elapsed time: 5999.69 secs
// Total time used
Data transferred: 84273.91 MB // a total of 84273.91 mb data transmission

Response time: 0.37 secs // corresponding time: 1.65 seconds: display the network connection speed
Transaction
Rate: 569.91 TRANS/sec // 569.91 requests per second: After the server
Throughput:
14.05 MB/sec // average data transferred per second
Concurrency: 213.42 // The actual maximum number of concurrent jobs

Successful transactions: 2564081 // number of successful processes
Failed transactions:
11 // number of failed processes
Longest transaction: 29.04 // the maximum duration of each transmission

Shortest transaction: 0.00 // the shortest time taken for each transmission

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.