What is Apache?
Apache is the world's number one web server software. It can run on almost all widely used computer platforms and is one of the most popular web server-side software due to its cross-platform and security features. It is fast, reliable and can be extended through a simple API to compile interpreters such as Perl/Python into the server.
What is nginx?
Nginx is a lightweight web server/reverse proxy server and email (IMAP/POP3) proxy server, released under the BSD-like protocol. Its characteristics are that it occupies less memory and has strong concurrency capabilities. In fact, nginx's concurrency capabilities do perform better among web servers of the same type. Most websites in mainland my country use nginx.
Which one has better performance, Apache or nginx?
Nginx has higher performance than Apache.
Reason:
nginx itself is positioned as a lightweight webserver, and advanced functions rely on configuration and loading module components. Apache itself is powerful, and its design also pursues strong stability.
The core reason is the way they handle network IO: nginx is asynchronous and non-blocking, while apache is synchronous blocking. This is also the reason why nginx's high performance and apache's high stability are guaranteed.
Nginx uses the latest epoll (Linux 2.6 kernel) and kqueue (freebsd) network I/O models, while Apache uses the traditional select model.
Currently, Squid and Memcached, which can withstand high concurrent access under Linux, both use the epoll network I/O model.
To handle the reading and writing of a large number of connections, the select network I/O model used by Apache is very inefficient.
Recommended learning: nginx tutorial
The above is the detailed content of Which one has higher performance, Apache or nginx?. For more information, please follow other related articles on the PHP Chinese website!