Nginx uses logs to output upstream server and its own processing time
Scenario: the backend of Nginx is followed by Tomcat. Now you need to count the processing time of implementing Nginx and the return time of backend server.
Purpose: for a client request, use the log to output the processing time of Nginx itself and the processing time of the upstream server.
Implementation: obtain the relevant information through the upstream_response_time variable of the upstream module.
Configuration:
1. Define logformat log_format timed_combined'$remote_addr-$remote_user [$time_local]'"$request" $status $body_bytes_sent'', $http_referer "$http_user_agent"'$request_time $upstream_response_time $pipe'
Request_time indicates how long it will take for Nginx to process the request. Upstream_response_time indicates the processing time of the upstream server. Pipe indicates whether http pipe is used
Use the log format:
Access_log / var/log/nginx/yourdomain.com.access.log timed_combined
66.249.71.173-[08/Nov/2010:14:16:18-0600] "GET / blog/2010/apr/30/installing-geodjango-dependencies-homebrew/ HTTP/1.1" 6569 "-" Mozilla/5.0 (compatible; Googlebot/2.1; + http://www.google.com/bot.html)" 0.640 0.640.
0.640 indicates that Nginx takes 0.640s to go to the corresponding client, in which the upstream server takes up 0.640s and does not spend any time, and does not use pipeline