In the web service based on nginx + tomcat architecture, users feel that the response is very slow. How to troubleshoot? You can check the access.log of nginx at the first time. The $request_time field is defined in log_format, which refers to the time from accepting user request data to sending reply data.
Is it slow due to nginx, tomcat or others?
log_format also provides the $upstream_response_time field, which refers to the time from when nginx establishes a connection to the backend to when it accepts the data and closes the connection.
That is to say:
If $request_time is not much different from $upstream_response_time, you need to use Btrace (Java application) and other means to locate the slow request of the upstream service tomcat.
If there is a big difference between the two, that is, the value of $upstream_response_time is relatively small, you need to check whether there is a performance bottleneck in the nginx module configuration or the network between nginx and the client.
The above introduces the location of the slow response problem of nginx+tomcat, including the content of tomcat and nginx. I hope it will be helpful to friends who are interested in PHP tutorials.