Concurrency performance test Apache Nginx

Source: Internet
Author: User
Tags epoll php tutorial sendfile
Concurrency Performance test
1 Purpose of testing
According to the test results of Apache and Nginx concurrency performance, the advantages and disadvantages of concurrency model are analyzed.
Performance evaluation items include: RPS (number of processing requests per second), CPU utilization, memory usage, maximum concurrency.
According to the advantages and disadvantages of Apache and Nginx concurrency model, the appropriate concurrency model framework is chosen.
2 test environment
1. Hardware environment
Server: Interl Server Borad
8-Core cpu,2g memory, 160G HDD,
Client: Same as server-side environment
2. Operating system
Operating system: Red Hat EnterPrise kernel Linux 2.6.18
Client: Red Hat EnterPrise kernel Linux 2.6.9
3. Network topology
Server and client connect a switch via a gigabit network
Server IP Address: 192.168.192.201
Client IP Address: 192.168.192.200
3 Test methods
3.1 Test Tools
Apache 2.2.10 comes with tools bench
Webbench 1.5
3.2 Test Steps
1, equipment inspection and installation
Check that all system devices are intact and connect the device to the host.
2. Network connection Check
Servers and clients are connected to the same switch with a gigabit network cable
3, operating System preparation
Start Red Hat Enterprise
Install the mouse driver, configure the network
4. Download, install, configure
Reference Appendix
5. Apache Test
Run Apache
Cd/usr/local/apache/bin
./apachectl-k Start
Test Apache service successfully started
Access under Windows: http://192.168.192.201/index.html
Appears "It works! The test page
Run the Apche bench test program
Cd/usr/local/apache/bin
./ab-c Clients-n Requests http://192.168.192.201/index.html
Run the Webbench test program
Cd/usr/local/bin
Webbench-c clients-t Time http://192.168.192.200/index.html
(Clients represents the number of users, requests represents the number of concurrent)
6. Nginx Test
Run Nginx
./nginx
Test Nginx Service successfully started
Access under Windows: http://192.168.192.201/index.html
The "Welcome to nginx!" page appears
In order to test the results of the contrast, the Apache test page index.html Copy Overlay nignx test page
Run the Apche bench test program
Cd/usr/local/apache/bin
./ab-c Clients-n Requests http://192.168.192.201/index.html
Run the Webbech test program
Cd/usr/local/bin
Webbench-c clients-t Time http://192.168.192.200/index.html

7. Record Test results
Record bench test results: Time taken for tests (test times, units: seconds), requests per second (number of requests processed per second)
Record Webbench test results: speed (processing requests per minute, in order to be consistent with Apache bench, log *30 to process requests per second), run time according to Operation command-T specified, default 30 seconds
View CPU Usage command: Top
Memory usage Command: FREE
4 Test Plan
Nginx Single Thread test
Nginx multithreaded Test
Apache woker Mode Test
Apache prefork Mode Test
5 Summary of data
Test configuration: Apache configuration Reference 7.4,nginx Configuration Reference 7.5
Raw data See original data xls
The data are summarized as follows:
Server Client RPS
Idle free (used) idle free (used)
Nginx Single process 102526K 185196K 20757
Nginx Multi-process Bayi 395444K 177405K 20861
Apahce prefork 154380K 178215K 30181
Apache worker 81506K Bayi 183166K 24669

6 Test conclusion

7 Appendices
7.1 Webbench Installation
Step action
Download the installation package wget http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz
Unzip the tar zxvf webbench-1.5.tar.gz
Compiling CD webbench-1.5
Make
Install make install
7.2 Apache Installation
Step action Instructions
Download the installation package in http://www.apache.org download package httpd-2.2.10.tar.gz latest stable version
Unzip the tar xvzf httpd-2.2.10.tar.gz
Compile options./configure--prefix=/usr/local/apache Installation path
--enable-module=shared shared memory between processes
--enable-module=rewrite
--enable-threads thread Support (worker mode valid)
--enable-shared=max
--with-mpm=worker Worker Mode selection
--with-mpm=prefork prefork Mode selection
--with-mpm=event I/O multiplexing support
Make compilation
Install make install
7.3 Nginx Installation
Step action Instructions
Download the installation package in http://sysoev.ru/nginx/download.html download package nginx-0.7.24.tar.gz latest stable version
Unzip the tar xvzf ginx-0.7.24.tar.gz
Compile the./configure--prefix=/usr/local/Installation path
Make compilation
Install make install
7.4 Apache Configuration
Apache configuration command:
Cd/usr/local/apache/conf
VI http.conf

Parameter configuration in Prefork mode:
Configure Apache
Prefork Mode--with-mpm=prefork
System startup creation process number Startservers 128//for Nginx comparable
Number of active sub-processes Serverlimit 50000
Number of processing connections in the child process lifetime Maxrequestsperchild 0//0 is unlimited
Maximum number of child processes maxclients 50000
Listening Port Listen 80
Timeout Timeout 300
KeepAlive keepAlive on
Sendfile Enablesendfile on

Worker Mode configuration:
Configuration Item Implementation
Worker Mode--with-mpm=worker
System startup creation process number Startservers 32
Number of active sub-processes Serverlimit 7812
Maximum number of threads maxclients 500000
Number of child process threads threadsperchild 64//equals the maximum value that Apache allows to set
Listening Port Listen 80
Timeout Timeout 300
KeepAlive keepAlive on
Sendfile Enablesendfile on


7.5 Nginx Configuration
Nginx configuration command:
Cd/usr/local/nginx/conf
VI nginx.conf
To test the Nginx configuration command:
./nginx–t


Single-Work process main configuration:
Configure Nginx
Process worker_processes 1;
Process processing connection number worker_connections 102400;
Listening on port server {
Listen 80;
}
Sendfile Sendfile on;
I/O multiplexing method use Epoll;

Multi-worker process configuration:
Configure Nginx
Process Worker_processes 16;
Process processing connection number worker_connections 102400;
Listening on port server {
Listen 80;
}
Sendfile Sendfile on;
I/O multiplexing method use Epoll;

The above describes the concurrency performance test Apache Nginx, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • 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.