nginx Service

1, nginx Introduction

Here Insert Picture Description
Nginx (the X-Engine) is a high-performance HTTP server and reverse proxy services, is also a IMAP / POP3 / SMTP services. Because for its stability, rich feature set, simple configuration files and low system resource is known.

Nginx is a lightweight Web server / reverse proxy server and e-mail (IMAP / POP3) proxy server, and released under a BSD-like agreement. It features occupy less memory, high concurrency, the ability to do concurrent nginx fact the same type of web server performance is better

In the case of high concurrent connections, Nginx Apache server is a good substitute.
Founder Igor Saisuoyefu
Here Insert Picture Description

2. Why nginx

Nginx is a high-performance Web server and reverse proxy, which has had a lot of very superior characteristics:

Reference Server Configuration stand-alone environment. Concurrent connections about 7000 + -8000. 20,000 + cluster mode

As a Web server : compared to Apache, Nginx use fewer resources to support more concurrent connections, reflecting higher efficiency, especially by this point the Nginx web hosting provider welcome. In response to support up to 50,000 concurrent connections.

As a load balancing server : Nginx either directly support Rails and PHP internally, can also support as an HTTP proxy server in foreign service. Nginx is written in C, regardless of the system or CPU resource consumption efficiency is much better than Perlbal.

As a mail proxy server : Nginx is also a very good mail proxy server (one of the purposes of the earliest development of this product is as a mail proxy server), Last.fm describes a successful and wonderful experience.

Nginx installation is very simple, very simple configuration file (also supports perl syntax), Bugs very little server : Nginx starts are particularly vulnerable, and can be done almost 7 * 24 uninterrupted operation, even if a few months do not need to run again start up. You can also upgrade the software version in the case of uninterrupted service.

3, IO multiplexing

The first method is the most traditional multi-process concurrency model (each come in a new I / O stream will be assigned a new process management.)
Here Insert Picture Description
The second method is the I / O multiplexing (single thread, by recording the track state of each I / O stream (our sock), and to manage a plurality of I / O streams.)

I / O multiplexing of the multiplexing means there is in fact track each Sock (I / O stream) recorded by a single thread in the same state

Managing a plurality of I / O streams. It's the reason the invention is to improve the handling capacity of as many servers. (Processing power)

In the same thread which, by way of DIP switches to simultaneously transmit a plurality of I / O streams. (Read-write)
Here Insert Picture Description

* 2, a request arrived, nginx receives requests to use epoll What is the process?

* Ngnix have a lot of connections come in, epoll they will have to monitor it, and then like a dial switch as who to whom the data will be allocated, then call phase

Code should be treated.

  • epoll.

epoll can say is I / O multiplexing the latest in a realization, and select poll epoll fixes most of the problems, such as:

• epoll thread-safe.

• epoll tell you which specific sock data, you do not have to go up.

3, asynchronous, non-blocking

A master process, two work processes

Each comes in a request, there will be a worker process to deal with. But not to what extent the whole process, to deal with it? deal with

Where the obstruction may occur, such as a server forwards the request to an upstream (rear), and return to waiting for a request. So, this process

The worker will not always be waiting, he would after sending a request to register an event: "If the upstream returned, let me know,

I then went dry. "So he went to rest. This is asynchronous. At this time, if another request comes in, he can quickly press this

Approach. This is a non-blocking IO and multiplexing. Once the upstream server returned, it will trigger this event, worker will be

Took over, this request will then go down. This is an asynchronous callback.

Published 48 original articles · won praise 18 · views 3660

Guess you like

Origin blog.csdn.net/wx912820/article/details/104822056
Recommended