Concurrency performance test apache nginx
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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

The methods that can query the Nginx version are: use the nginx -v command; view the version directive in the nginx.conf file; open the Nginx error page and view the page title.

How to configure an Nginx domain name on a cloud server: Create an A record pointing to the public IP address of the cloud server. Add virtual host blocks in the Nginx configuration file, specifying the listening port, domain name, and website root directory. Restart Nginx to apply the changes. Access the domain name test configuration. Other notes: Install the SSL certificate to enable HTTPS, ensure that the firewall allows port 80 traffic, and wait for DNS resolution to take effect.

How to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

Deploying a ZooKeeper cluster on a CentOS system requires the following steps: The environment is ready to install the Java runtime environment: Use the following command to install the Java 8 development kit: sudoyumininstalljava-1.8.0-openjdk-devel Download ZooKeeper: Download the version for CentOS (such as ZooKeeper3.8.x) from the official ApacheZooKeeper website. Use the wget command to download and replace zookeeper-3.8.x with the actual version number: wgethttps://downloads.apache.or

Create a container in Docker: 1. Pull the image: docker pull [mirror name] 2. Create a container: docker run [Options] [mirror name] [Command] 3. Start the container: docker start [Container name]

Starting an Nginx server requires different steps according to different operating systems: Linux/Unix system: Install the Nginx package (for example, using apt-get or yum). Use systemctl to start an Nginx service (for example, sudo systemctl start nginx). Windows system: Download and install Windows binary files. Start Nginx using the nginx.exe executable (for example, nginx.exe -c conf\nginx.conf). No matter which operating system you use, you can access the server IP
