nginx reverse proxy advantage of features in principle (a)

Speaking of reverse proxy, first of all to say about the concept of reverse proxy

Reverse proxy (Reverse Proxy) mode refers to the proxy server to accept the connection request from a client, and then forwards the request to the web server on the network (possibly apache, nginx, tomcat, iis, etc.) and the web server on the results obtained returned to the requesting client connection, in which case the external proxy server on the performance of a server.

nginx is a lightweight web server / reverse proxy and e-mail proxy server. Due to its stability, and rich feature set, simple configuration file consumption and low system resources and civilization.

nginx core features

① Cross-platform: nginx can run on most OS compilation, but also windows version

② deployment: configuration is simple, easy to use

③ non-blocking. High concurrent connections: official test capable of supporting 50,000 concurrent connections, the actual production environment can go 2-30000 number of concurrent connections. (This is the latest model epoll second place to nginx used); before calling a non-blocking refers not get the results immediately, the call does not block the current thread. (Like on their Mom is cooking, during the rice well, you can do anything, without waiting for dry food, cooked)

④ Event-driven: nginx communication using epoll model, support for larger concurrent connections. Non-blocking state by constantly checking to determine whether the time to read and write, so bring a lot of overhead, so there will be a non-blocking asynchronous event handling mechanism. This mechanism allows you to simultaneously monitor multiple events, they are non-blocking calls, but you can set the timeout within the timeout period, if there is an event ready to return. This mechanism solves both problems with a non-blocking call blocking call

To epoll model as an example: When the event number is not ready, then put inside the epoll queue, if there is an event ready, then go deal; when the event is not ready, waiting in the epoll queue. This ability to achieve a large number of concurrent treatment nginx herein refers to concurrent requests and the unprocessed request. Only one thread, at the same time it can handle only one request, of course, but just be constantly switching between requests, but also due to the asynchronous switching event is not ready, and take the initiative to let out, can be understood as an event loop processing ready . So by non-blocking asynchronous event handling mechanism, nginx achieved by the process loop ready to handle multiple events, in order to achieve high concurrency and lightweight.

⑤Master / Worker structure: a master process, generate one or more worker process. When major role in monitoring the process worker, the worker process is the real process of handling requests, the process will not affect each other, a process exits, another process was still working, the service will not be interrupted, master process will restart soon the new worker process.

⑥ small memory consumption: handle large concurrent request memory consumption is very small. In the 30,000 concurrent connections, open 10 nginx program consumes only 150M memory (15M * 10)

⑦ built-health check function: if nginx proxy backend of a web server is down, will not affect front-end access.

⑧ save bandwidth: support GZIP compression, you can add a local browser cache HEADER head.

⑨ high stability: a reverse proxy, the probability of downtime is minimal.

nginx reverse proxy server topology diagram ---

 

Guess you like

Origin www.cnblogs.com/xpd676/p/11576012.html