[Nginx 1] - Nginx introduction (forward proxy reverse proxy load balancing dynamic and static separation)

1. What is Nginx

Nginx[engine x] is a free open source web server, an HTTP and reverse proxy server, a mail proxy server, and a general purpose TCP/UDP proxy server, originally written by Russian software engineer Igor Sysoev.

2. Why use Nginx

nginx focuses on high performance, high concurrency and low memory usage. It can provide stable services to the website under high concurrency.

Three, the characteristics of Nginx

background

First, there is a user C, three servers S1, S2 and S3, but S1 is open to the external network, S2 and S3 are not open to the external network, and there is a resource D, which is placed on the servers S2 and S3.

forward proxy

User C clearly knows that the resource D he wants to access is on server S2, but the user has no way to directly access server S2. User C thinks that servers S1 and S2 are in the same LAN and can access each other, and he can access server S1, so user C C uses server S1 to access resource D on server S2.

insert image description here
For user C, the forward proxy knows exactly which server the resource D he wants to access is on; for server S1, he only acts as an intermediate proxy for user C; and for server S2, he only knows to access his resources It is server S1 that does not know the existence of user C at all.

reverse proxy

According to the above background, user C does not know that resource D is on servers S2 and S3, he only knows that he can get resource D by accessing server S1, so he directly accesses server S1 every time, but provides it to user C The resources are all from the server S2 or S3.
insert image description here
For the reverse proxy, user C does not know where the resource D is, nor does he know who provides it.
For the server S1, it accepts the user's request every time, and then sends the request to the server S2 or S3 that provides the resource D according to the scheduling policy. For the servers S2 and S3, they also do not know the truth of accessing the resource D. Whoever the user is, just interacts with the server S1.

load balancing

According to certain rules, Nginx distributes requests to each server, instead of concentrating requests on a single server to distributing requests to multiple servers to reduce the pressure on a single server. This is load balancing.
insert image description here

static and dynamic separation

Dynamic and static separation refers to the separation of static requests and dynamic requests in the web service architecture, thereby improving the overall service access performance.

insert image description here

Nginx dynamic and static separation means that nginx classifies and forwards customer requests, static resource requests (such as html, css, pictures, etc.) are processed by static resource servers, and dynamic resource requests (such as jsp pages, servlets) are processed by tomcat servers deal with. Tomcat can handle dynamic and static resources, but tomcat is not efficient in handling static resources. The use of nginx to achieve dynamic and static separation allows tomcat to focus on and process dynamic resources, and static resources are uniformly processed by the static resource server, thereby improving the performance of the entire service system.

Guess you like

Origin blog.csdn.net/wangwei021933/article/details/129664361