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.

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


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

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1
Powerful PHP integrated development environment

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool