Php script stress testing. Details about AB commands for linux and apache

Source: Internet
Author: User
Tags htons
1. there are two basic options-c-n :. ab-c100-n10000127.0.0.1index.php-c100 is: 100 Concurrent-n10000 each time that: a total of 10000 requests are sent 2. test result analysis [junjie2 @ loginhtdocs] $ data1apachebinab-c1000-n5000010.10.10.10a.

1. there are two basic options-c-n :. /AB-c 100-n 10000 http: // 127.0.0.1/index. php-c 100: 100-n 10000 concurrent requests each time: a total of 10000 requests are sent. 2. test result analysis [junjie2 @ login htdocs] $/data1/apache/bin/AB-c 1000-n 50000 http: // 10.10.10.10/.

1. The two most basic options-c-n
Example:./AB-c 100-n 10000 http: // 127.0.0.1/index. php

-C 100: 100 concurrent requests each time
-N 10000: A total of 10000 requests are sent.

2. Test Result Analysis

[Junjie2 @ login htdocs] $/data1/apache/bin/AB-c 1000-n 50000 "http: // 10.10.10.10/a. php"
This is apachetings, Version 1.3d <$ Revision: 1.73 $> apache-1.3
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 10.65.129.21 (be patient)
Completed5000 requests
Completed10000 requests
Completed15000 requests
Completed20000 requests
Completed25000 requests
Completed30000 requests
Completed35000 requests
Completed40000 requests
Completed45000 requests
Finished 50000 requests
Server Software: Apache/1.3.33
Server Hostname: 10.65.129.21
Server Port: 80

Document Path:/a. php // requested resource
Document Length: 0 bytes // Length returned by the Document, excluding the corresponding Header

Concurrency Level: 1000 // number of concurrent jobs
Time taken for tests: 48.650 seconds // total request Time
Complete requests: 50000 // Total number of requests
Failed requests: 0 // number of Failed requests
Broken pipe errors: 0
Total transferred: 9750000 bytes
HTML transferred: 0 bytes
Requests per second: 1027.75 [#/sec] (mean) // average number of Requests per second
Time per request: 973.00 [MS] (mean) // average Time consumed by each request
Time per request: 0.97 [MS] (mean, messaging SS all concurrent requests) // is the Time above divided by the number of concurrent requests
Transfer rate: 200.41 [Kbytes/sec] received // Time Transmission rate

Connnection Times (MS)
Min mean [+/-sd] median max
Connect: 0 183 2063.3 0 45003
Processing: 28 167 770.6 85 25579
Waiting: 21 167 770.6 85 25578
Total: 28 350 2488.8 85 48639

Percentage of the requests served within a certain time (MS)
50% 85 // 50% of requests are completed within Ms
66% 89
75% 92
80% 96
90% 168
95% 640
98% 984
99% 3203
100% 48639 (last request)

3. Using 127.0.0.1 for access can eliminate network factors. However, in Linux, using the external ip address of the local machine does not allow access to the network card, and there is no network consumption.

AB help:

1. we know that when testing with AB, the maximum concurrency cannot exceed 1024. In fact, AB itself does not have this limit, but the system limits the maximum number of files opened by each process to 1024. For details, see ulimit:

[Root @ localhost ~] # Ulimit-
Core file size (blocks,-c) 0
Data seg size (kbytes,-d) unlimited
File size (blocks,-f) unlimited
Pending signals (-I) 1024
Max locked memory (kbytes,-l) 32
Max memory size (kbytes,-m) unlimited
Open File (-n) 1024
Pipe size (512 bytes,-p) 8
POSIX message queues (bytes,-q) 819200
Stack size (kbytes,-s) 10240
Cpu time (seconds,-t) unlimited
Max user processes (-u) 32765
Virtual memory (kbytes,-v) unlimited
File locks (-x) unlimited

In addition, the option "open files" cannot be changed to unlimited in general systems, as shown below:
[Root @ localhost ~] # Ulimit-n unlimited
Bash: ulimit: open files: cannot modify limit: Operation not permitted

However, slightly larger or smaller modifications are allowed. Let's try to make them smaller:
[Root @ localhost ~] # Ulimit-n 1020
[Root @ localhost ~] # Ulimit-n
1020
[Root @ localhost ~] #

In the AB test, the error is as follows:

Socket (PF_INET, SOCK_STREAM, IPPROTO_IP) = 1019
Ioctl (1019, FIONBIO, [1]) = 0
Gettimeofday ({1243919682,867 688}, NULL) = 0
Connect (1019, {sa_family = AF_INET, sin_port = htons (80), sin_addr = inet_addr ("10.55.38.18")}, 16) =-1 EINPROGRESS (Operation now in progress)
Socket (PF_INET, SOCK_STREAM, IPPROTO_IP) =-1 EMFILE (Too workflow open files)
Close (-1) =-1 EBADF (Bad file descriptor)
If 1,019th files can still be opened normally, the next one will report the Too program open files error.

It is indeed valid, so let's modify it a little bigger:

[Root @ localhost ~] # Ulimit-n 10240
[Root @ localhost ~] # Ulimit-n
10240
[Root @ localhost ~] #

However, we found that the change was not feasible, but here we came up with the AF_AX25 term:
Socket (PF_INET, SOCK_STREAM, IPPROTO_IP) = 1024
Ioctl (1024, FIONBIO, [1]) = 0
Gettimeofday ({1243919592,254 950}, NULL) = 0
Connect (1024, {sa_family = AF_INET, sin_port = htons (80), sin_addr = inet_addr ("10.55.38.18")}, 16) =-1 EINPROGRESS (Operation now in progress)
Socket (PF_INET, SOCK_STREAM, IPPROTO_IP) = 1025
Ioctl (1025, FIONBIO, [1]) = 0
Gettimeofday ({1243919592,255 242}, NULL) = 0
Connect (1025, {sa_family = AF_AX25, sa_data = "\ 0P \ n7 & \ 22 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0"}, 16) =-1 EAFNOSUPPORT (Address family not supported by protocol)

This AF_AX25 may be caused by buffer overflow, but you are not sure about it :).

In addition:
-N can specify the maximum number of requests, but it cannot exceed 50000 :)
-V n when n> = 2, the http request header sent and the http header and content of the response can be displayed. Do not do this during stress testing :)

Http://johnnyhg.javaeye.com/blog/523818

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.