Why use Nginx?
In traditional Web projects, the amount of concurrency is small and users use it less. So in the case of low concurrency, users can directly access the tomcat server, and then the tomcat server returns messages to the user. For example, we upload pictures:
Of course we know that in order to solve concurrency, we can use load balancing: that is, we add a few more tomcat servers. When a user visits, the request can be submitted to an idle tomcat server.
But in this case there may be a problem: uploading pictures. We uploaded the image to tomcat1. When we wanted to access the image, tomcat1 happened to be working, so the access request was handed over to other tomcat operations, and the data between tomcats was not synchronized, so what happened to us The requested image was not found.
In order to solve this situation, we came up with distributed. We specially built a picture server to store pictures. In this way, when we all upload pictures, no matter which server receives the pictures, they will be uploaded to the picture server.
An http server needs to be installed on the image server, and you can use tomcat, apache, or nginx.
You may ask after seeing this, since we want to choose an http server, why not continue to use tomcat, but use Nginx?
The reasons are as follows: nginx is often used as a static content service and proxy server (not your FQ proxy), directly forwarding external requests to subsequent application services (tomcat, django, etc.), and tomcat is more used for doing things. An application container allows Java web apps to run in it, corresponding to the same level as jboss, jetty and other things.
Recommended tutorial:nginx tutorial
The above is the detailed content of Why does php use nginx as a proxy?. For more information, please follow other related articles on the PHP Chinese website!