Nginx basic introduction and principle

1.1nginx basic introduction

1. The principle of nginx high concurrency (multi-process + epool achieves high concurrency)

1. After Nginx is started, there will be a master process and multiple independent worker processes

2. Each child process has only one thread. The IO multiplexing model epoll is adopted to achieve high concurrency

2.epoll can realize the principle of high concurrency

1. In epoll(), the kernel maintains a linked list. The epoll_wait method can obtain the length of the linked list. If it is not 0, the file descriptor is ready.

2. In the kernel implementation, epoll is implemented based on the callback function established with the device driver on each sockfd

3. When an event on a sockfd occurs, its corresponding callback function will be called to This sockfd is added to the linked list, and the others in the “idle” state will not

4 .epoll obtains the file description in the linked list above, here uses the memory mapping (mmap) technology to avoid the overhead caused by copying a large number of file descriptors

Memory mapping (mmap): A memory mapped file is a mapping from a file to a block of memory, so there is no need to execute on the file anymore I/O operations

3. Comparison between nginx and apache

(1) Advantages of nginx over apache span>

1. Lightweight, like a web service, it takes up less memory and resources than apache

2. Anti-concurrency, nginx processes requests asynchronously and non-blocking, while apache is blocking Yes, nginx can maintain low resources, low consumption and high performance under high concurrency

3. Highly modular design, relatively simple to write modules, active community, fast production of various high-performance modules

(1) Advantages of apache over nginx

1.apache More mature, less bugs, better stability

2.rewrite, better than nginx Rewrite is powerful

3. There are so many modules, you can find almost anything you can think of.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4635 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.