Introduction and basic principles of nginx

1.1nginx basic introduction

1.nginx high concurrency principle (multi-process + epool achieve high concurrency)

1.Nginx after the start, there will be a master process and several independent worker process

2. Each child process has only one thread, IO multiplexing epoll model used to achieve high concurrency

2. epoll principle to achieve high concurrency

1.epoll () in the kernel maintains a list, epoll_wait ways to get to the length of the list, do not know the file descriptor 0 ready

2. epoll kernel implementation is to set up each device driver in accordance with the above sockfd implemented callback

3. When the event on a sockfd happen, and it corresponds to the callback function is called, sockfd to join this list, no other is in the "idle" state

4.epoll above the list to obtain documents described here using memory mapping (mmap) technology, avoid copying a large number of file descriptors the overhead

Memory mapping (the mmap) : memory mapped files, a file is mapped to a memory, the file will not have to perform I / O operations

3, nginx and apache compare

(1) nginx advantages with respect to the apache

1. Lightweight, also from the web service, take up less memory than apache and resources

2. Anti-concurrent, non-blocking nginx processing request is asynchronous, and the apache is obstructive in the high concurrent nginx high performance maintaining low resource consumption

3. The highly modular design, the preparation module is relatively simple, community activists, all kinds of high-performance modules produced rapidly ah

(1) apache advantages with respect to nginx

1.apache more mature, less bug, good stability

2.rewrite, stronger than the rewrite nginx

3. Module over more basic thought can be found

Guess you like

Origin www.cnblogs.com/junjun511/p/11299357.html