Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx uses logs to output upstream server and its own processing time

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report