tornadoweb / tornado

Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.
http://www.tornadoweb.org/
Apache License 2.0
21.76k stars 5.51k forks source link

Is there a way to get the request queue time or requset come time #3440

Open Y-Destiny opened 2 weeks ago

Y-Destiny commented 2 weeks ago

Description:

I've created a Tornado service using HTTPServer, where each request triggers an HTTPClient call to another more time-consuming service. When running the service as a single process and making concurrent requests, later requests wait for earlier ones to complete before they are processed.

I've reviewed the RequestHandler source code and noticed that the request_time function only measures the duration from the start of processing (initialization) to the end of the request, which doesn't include time spent waiting in the queue.

I would like to obtain the actual time each request spends in the queue before it starts being processed, as well as the total time (queue time + processing time) it takes to complete each request. This information would allow for more accurate request analysis.

Is there currently a way to obtain the queue time or the time when each request first arrives at the server?