Home  >  Article  >  Backend Development  >  Concurrency performance test apache nginx

Concurrency performance test apache nginx

WBOY
WBOYOriginal
2016-08-08 09:32:581074browse

Concurrency performance test
1 Test purpose
Based on the concurrency performance test results of Apache and Nginx, analyze the respective advantages and disadvantages of their concurrency models.
Performance evaluation items include: RPS (number of requests processed per second), CPU usage, memory usage, and maximum number of concurrencies.
Choose an appropriate concurrency model framework based on the advantages and disadvantages of the Apache and Nginx concurrency models.
2 Test environment
1. Hardware environment
Server: Interl server Borad
8-core CPU, 2G memory, 160G hard drive,
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
The server and client are connected to a switch through a 100M network cable
Server IP address: 192.168.192.201
Client IP address: 192.168.192.200
3 Testing Methods
3.1 Testing tools
Apache 2.2.10 comes with tool bench
webbench 1.5
3.2 Testing steps                                 1. Equipment inspection and installation
Check whether all system devices are intact and available, and connect the devices to the host.
2. Network connection check
The server and client are connected to the same switch using 100M network cable
3. Operating system preparation
Start Red Hat Enterprise
Install mouse driver and configure network
4. Download, install and configure
Refer to the appendix
5. apache test
Run apache
cd /usr/local/apache/bin
./apachectl -k start
Test apache service started successfully
Visit under windows: http://192.168.192.201/index.html
The "it works!" test page appears
Run apche bench test program
cd /usr/local/apache/bin
./ab -c Clients -n Requests http://192.168.192.201/index.html
Run 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 concurrency)
6. Nginx test
Run nginx
./nginx
Test nginx service started successfully
Visit under windows: http://192.168.192.201/index.html
The "Welcome to nginx!" page appears
In order to test the comparability of the results, copy the apache test page index.html to cover the nignx test page
Run apche bench test program
cd /usr/local/apache/bin
./ab -c Clients -n Requests http://192.168.192.201/index.html
Run 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 time, unit: seconds), Requests per second (number of requests processed per second)
Record the webbench test results: Speed ​​(number of requests processed per minute, in order to be consistent with Apache bench, *30 is converted into the number of requests processed per second during recording), the running time is specified according to the operation command -t, the default is 30 seconds
Check CPU usage command: top
Memory usage command: free
4 Test plan
Nginx single thread test
Nginx multi-thread testing
Apache worker mode test
Apache prefork mode testing
5 Data Summary
Test configuration: Apache configuration reference 7.4, Nginx configuration reference 7.5
For original data, please refer to original data xls
The data is summarized as follows:
server client RPS
Idle Free (used) Idle Free (used)
Nginx single process 79 102526K 82 185196K 20757
Nginx multi-process 81 395444K 85 177405K 20861
Apahce prefork 38 154380K 75 178215K 30181
Apache worker 41 81506K 81 183166K 24669

6 Test conclusion

7 Appendix
7.1 Webbench installation
Steps Operation
Download the installation package wget http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz
Unzip tar zxvf webbench-1.5.tar.gz
Compile cd webbench-1.5
make
Install make install
7.2 Apache installation
Step Operation Description
Download the installation package Download the software package httpd-2.2.10.tar.gz at http://www.apache.org The latest stable version
Unzip tar xvzf httpd-2.2.10.tar.gz
Compilation options ./configure --prefix=/usr/local/apache Installation path
--enable-module=shared Shared memory between processes
--enable-module=rewrite
--enable-threads Thread support (worker mode is valid)
--enable-shared=max
--with-mpm=worker Worker mode selection
--with-mpm=prefork Prefork mode selection
--with-mpm=event I/O multiplexing support
Make compile Install make install
7.3 Nginx installation
Step Operation Description
Download the installation package Download the software package nginx-0.7.24.tar.gz at http://sysoev.ru/nginx/download.html The latest stable version
Unzip tar xvzf ginx-0.7.24.tar.gz
Compile ./configure --prefix=/usr/local/ Installation path
Make Compile
Install make install
7.4 Apache configuration
Apache configuration command:
cd /usr/local/apache/conf
vi http.conf

Parameter configuration in prefork mode:
Configuration Apache
prefork mode --with-mpm=prefork
Number of processes created at system startup StartServers 128 //Comparable to Nginx
Number of active child processes ServerLimit 50000
Number of connections processed during the life cycle of the child process MaxRequestsPerChild 0 // 0 means no limit
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
Number of processes created during system startup StartServers 32
Number of active child processes ServerLimit 7812
Maximum number of threads MaxClients 500000
Number of child process threads ThreadsPerChild 64 //Equal to the maximum value allowed by Apache
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
Test Nginx configuration commands:
./nginx –t


Main configuration of single worker process:
Configuration Nginx
Process worker_processes 1;
Number of connections processed by the process worker_connections 102400;
Listening port server {
Listen 80;
}
Sendfile sendfile on;
I/O multiplexing method use epoll;

Multi-worker configuration:
Configuration Nginx
Process worker_processes 16;
Number of connections processed by the process worker_connections 102400;
Listening port server {
Listen 80;
}
Sendfile sendfile on;
I/O multiplexing method use epoll;
The above introduces the concurrent performance test apache nginx, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

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