Using Apache ab to perform http performance testing

Using Apache ab to perform http performance testing

Mac comes with Apache environment

Open Terminal and enter sudo apachectl -v (you may need to enter your machine secret). The Apache version is shown below

Then enter sudo apachectl start and Apache will start. Open the Safari browser and enter "http://localhost" in the address bar. You should see a page with the content "It works!". It is located in "/Library/WebServer/Documents/", which is the default root directory of Apache.

Apache's installation directory is: /etc/apache2/, etc is hidden by default. There are three ways to view:

1. Right-click Finder in the dock, select "Go to Folder", and enter "/etc"
2. In finder -> Go -> Go to folder, then enter /etc
3. You can enter "open /etc" in the terminal

Windows can go to http://httpd.apache.org/download.cgi to download, or install from the command line

1. Install Apache

sudo port install apache2

Start Apache: sudo apachectl start

2. brew install pcre

3. wget http://ftp.yz.yamagata-u.ac.jp/pub/network/apache//httpd/httpd-2.4.4.tar.bz2

(1) Decompression
(2) ./configure
(3) make && make install
(4) sudo cp support/ab /usr/sbin

4. ab -n 1000 -c 10 http://localhost:3000/ The last slash is essential

For this ab -n1000 -c10 http://localhost:3000/ command, under the Windows system, you need to first use the cd command to locate the bin folder of your Apache installation directory. . .

Parameter description of ab

-n The number of requests to execute

-c The number of concurrent

-t Maximum time to wait for return

-b TCP send and receive buffer size, unit (byte)

-p uses post (also needs to define -T parameter)

-u Use put (also need to define -T parameter)

-T content-type, for example application/x-www-form-urlencoded, default is text/plain

-w prints the results in an HTML table

-x table attributes

-y tr line attributes

-z td column attributes

-C Set cookie, for example, Apache=1234

-H header line, for example Accept-Encoding:gzip

-k Whether to mark HTTP Keep Alive

Test results:

This is ApacheBench, Version 2.3 <$Revision: 1663405 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (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
Completed 1000 requests
Finished 1000 requests


Server Software:  
Server Hostname: localhost
Server Port: 3000

Document Path: /
Document Length: 14 bytes

Concurrency Level: 10
Time taken for tests: 0.323 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 115000 bytes
HTML transferred: 14000 bytes
Requests per second: 3097.37 [#/sec] (mean)
Time per request: 3.229 [ms] (mean)
Time per request: 0.323 [ms] (mean, across all concurrent requests)
Transfer rate: 347.85 [Kbytes/sec] received

Connection Times (ms)
    min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 1 3 2.2 2 16
Waiting: 1 3 2.2 2 16
Total: 1 3 2.2 2 16

Percentage of the requests served within a certain time (ms)
 50% 2
 66% 3
 75% 3
 80% 4
 90% 5
 95% 7
 98% 13
 99% 15
 100% 16 (longest request)

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of the use of Apache performance testing tool ab
  • Apache AB performance testing tool usage tutorial
  • Analyzing ab performance test results under Apache

<<:  Next.js Getting Started Tutorial

>>:  A brief introduction to the command line tool mycli for operating MySQL database

Recommend

Detailed explanation of querying JSON format fields in MySQL

During the work development process, a requiremen...

Two ways to use react in React html

Basic Use <!DOCTYPE html> <html lang=&qu...

Detailed explanation of keepAlive usage in Vue front-end development

Table of contents Preface keep-avlive hook functi...

JavaScript implements circular carousel

This article shares the specific code of JavaScri...

SQL query for users who have logged in for at least n consecutive days

Take 3 consecutive days as an example, using the ...

SQL ROW_NUMBER() and OVER() method case study

Syntax format: row_number() over(partition by gro...

Detailed explanation of key uniqueness of v-for in Vue

Table of contents 1. DOM Diff 2. Add key attribut...

How to modify the user and group of a file in Linux

In Linux, when a file is created, the owner of th...

Docker Data Storage Volumes Detailed Explanation

By default, the reading and writing of container ...

Pure HTML+CSS to achieve Element loading effect

This is the effect of the Element UI loading comp...

HTML uses marquee to achieve text scrolling left and right

Copy code The code is as follows: <BODY> //...

Example of javascript bubble sort

Table of contents 1. What is Bubble Sort 2. Give ...

jQuery realizes the scrolling effect of table row data

This article example shares the specific code of ...

Pure CSS to add style to select (no script) implementation

Change the default style of select, usually throug...