search
HomeBackend DevelopmentPHP TutorialWeb stress testing tool apache -ab explained_PHP tutorial

Explanation of the web stress testing tool apache -ab

Many web stress testing tools are now paid, but apache comes with a free stress testing tool, the ab tool (Order). Specifically, you can find an ab.exe file in the bin directory under the root directory of Apache. Use it to roughly test the performance of your own program.

The specific usage is as follows, excerpted from the Internet. If there are any errors, please correct them.

Format

ab [options] [http://]hostname[:port]/path

Parameters

-n requests Number of requests to perform
//The number of requests executed in the test session. By default, only one request is executed

-c concurrency Number of multiple requests to make
//The number of requests generated at one time. The default is one at a time.

-t timelimit Seconds to max. wait for responses
//Maximum number of seconds for the test to take place. Its internal implicit value is -n 50000. It can limit the testing of the server to a fixed total time. By default, there is no time limit.

-p postfile File containing data to POST
//File containing data that needs to be POSTed.

-T content-type Content-type header for POSTing
//Content-type header information used by POST data.

-v verbosity How much troubleshooting info to print
//Set the verbosity of displayed information - 4 or greater will display header information, 3 or greater will display response codes (404, 200, etc.), 2 or greater will display warnings and other information. -V Display version number and exit.

-w Print out results in HTML tables
//Output the results in HTML table format. By default, it is a two-column width table with a white background.

-i Use HEAD instead of GET
//Perform 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 Attach a Cookie: line to the request. Its 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)

-A attribute Add Basic WWW Authentication, the attributes
//are a colon separated username and password.

-P attribute Add Basic Proxy Authentication, the attributes
//are a colon separated username and password.

//-P proxy-auth-username:password Provides BASIC authentication trust to a relay proxy. The username and password are separated by a : and sent in base64 encoding. This string will be sent regardless of whether the server requires it (i.e. whether a 401 authentication requirement code is 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 Set the string of attributes. There are various statically declared fixed-length buffers in the defective program. Additionally, the parsing of command line arguments, server response headers, and other external input is trivial, which can have undesirable consequences. It is not a complete implementation of HTTP/1.x; it only accepts certain 'expected' response formats. Frequent use of strstr(3) may cause performance issues, i.e., you may be testing the performance of ab rather than the server.
There are many parameters, generally we just use -c and -n parameters. For example:
Open cmd and enter the following code.
cd C:Apache2.2bin
ab -n 1000 -c 100 [url]http://zf.guqin.com/index/index[/url]
This means handling 100 requests simultaneously and running the index.php file 1000 times. Here's what it prints out.
This is ApacheBench, Version 2.0.41-dev apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, [url]http://www.zeustech.net/[/url]
Copyright (c) 1998-2002 The Apache Software Foundation, [url]http://www.apache.org/[/url]
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.2.8
//Platform apache version 2.2.8
Server Hostname: zf.guqin.com
//Server host name
Server Port:         80
//Server port
Document Path: /index.php
//Test page document
Document Length: 1018 bytes
//Document size
Concurrency Level: 1000
//Concurrency count
Time taken for tests: 8.188731 seconds
//The duration of the entire test
Complete requests: 1000
//Number of completed requests
Failed requests: 0
//Number of failed requests
Write errors:         0
Total transferred: 1361581 bytes
//Network transmission volume in the entire scene
HTML transferred: 1055666 bytes
//HTML content transmission volume in the entire scene
Requests per second: 122.12 [#/sec] (mean)
//One of the indicators that everyone is most concerned about is equivalent to the number of transactions per second in LR. The mean in parentheses indicates that this is an average value
Time per request: 8188.731 [ms] (mean)
//The second indicator that everyone is most concerned about is equivalent to the average transaction response time in LR. The mean in parentheses indicates that this is an average value
Time per request: 8.189 [ms] (mean, across all concurrent requests)
//Average of actual running time of each request
Transfer rate: 162.30 [Kbytes/sec] received
//The average traffic on the network per second can help eliminate whether there is a problem that excessive network traffic leads to 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 4554
Total: 813 1638 1338.9 1093 7785
//The decomposition of time spent on the network, the specific algorithm of each data is 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 status of all requests in the entire scenario. In the scenario, each request has a response time, 50% of the user response time is less than 1093 milliseconds, 60% of the user response time is less than 1247 milliseconds, and the maximum response time is less than 7785 milliseconds
Since for concurrent requests, the CPU does not actually process them at the same time, but rotates them one by one according to the time slice obtained by each request, so basically the first Time per request time is approximately equal to the second Time per request time multiplied by Number of concurrent requests.

Articles you may be interested in

  • The ten best web website performance testing software tools
  • php bom removal tool, php batch removal of bom code
  • Poll shows most Americans predict Obama will be re-elected
  • The classic dialogue between programmers and testers. These are summarized and shared by foreign programmers, saying they are universally applicable?
  • A collection of web front-end development gadgets
  • js gets the height of the scroll bar from the top and bottom of the browser, compatible with ie and firefox
  • php pushes elements into the array head ( Usage of array_unshift)
  • Software test engineer career introduction and planning

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/860675.htmlTechArticleWeb stress testing tool apache -ab explains that many web stress testing tools are paid now, but apache comes with it A free stress testing tool, the ab tool (command). Specifically...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools