Brief introduction
Nginx ("Engine X") is a high-performance HTTP and reverse proxy server, also a IMAP/POP3/SMTP proxy server;
As a lightweight Web server, with less memory, concurrency and other advantages, is high-connection concurrency scenario Apache Good alternative;
This article mainly introduces Nginx as a Web server, compared to the performance advantages of Apache;
The next article will introduce Nginx as the direction of the proxy server implementation;
Important Features
Non-blocking: During data replication, the first phase of disk I/O is non-blocking;
Event-driven: The communication mechanism uses the EPOLL model to support larger concurrent connections;
Master/worker structure: A master process that generates one or more worker processes;
Infrastructure architecture
How Nginx achieves high concurrency:
The I/O model employs an asynchronous, non-blocking event-driven mechanism that processes multiple prepared events, such as the epoll mechanism, from a process.
The difference between Nginx and Apache for high concurrency processing:
For Apache, each request will have a single worker thread, and when the concurrency increases, it will also produce a large number of worker threads, resulting in a sharp increase in memory consumption, while the context switch of the thread will also lead to higher CPU overhead, resulting in severe performance degradation in high concurrency scenarios;
For Nginx, a worker process has only one main thread, and through event-driven mechanism, it realizes the cyclic processing of multiple prepared events, thus achieving lightweight and high concurrency;
Deployment Configuration
Installation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
Yum-y Groupinstall "Development tools" Yum-y Groupinstall "Server Platform Development" |