Why nginx reverse proxy can reduce the load on the upstream server.
Generally speaking, the public network has high latency. The request connection between the client and nginx goes through the public network, and nginx first Cache these requests, and wait for all the request data to be completed before nginx makes a request to the intranet server, which reduces the cost of public network delay and also reduces the time a connection takes up the server program. (Recommended learning: nginx tutorial)
Reason:
Because tcp may not be able to transmit all the data at once, so one connection may It takes a long time to transmit all the required data, and if such idle connections are directly connected to the server, it will increase the burden on the server. And nginx has made great optimizations in this regard and can carry more With multiple connections, idle connections will not occupy too much memory, so nginx as a reverse proxy can reduce the load on the upstream server.
Reverse proxy: Reverse proxy (ReverseProxy) refers to using a proxy server to accept connection requests on the Internet, and then forwards the request to the server on the internal network, and The results obtained from the server are returned to the client requesting a connection on the Internet. Simply put, the real server cannot be directly accessed by the external network, and access must be through a proxy.
The role of reverse proxy
1. Prevent the main server from being maliciously attacked
2. Provide implementation support for load balancing and dynamic and static separation
The reason why nginx is widely used, I think, is due to its flexible configuration. One nginx.conf file solves most problems, whether it is nginx creating a virtual server, nginx reverse proxy server, or nginx load balancing. Almost everything is done in this configuration file.
The server is only responsible for setting up nginx and running it. Moreover, it is lightweight and can achieve better results without occupying too many server resources. It is a very highly recommended server
The above is the detailed content of Why use Nginx reverse proxy. For more information, please follow other related articles on the PHP Chinese website!