# Possible causes for request time taking twice as long as upstream response time

**URL:** <https://www.ruby-forum.com/t/possible-causes-for-request-time-taking-twice-as-long-as-upstream-response-time/202717>\
**Category:** NGINX\
**Created:** [February 4, 2011, 7:25am UTC](https://www.ruby-forum.com/t/possible-causes-for-request-time-taking-twice-as-long-as-upstream-response-time/202717 "2011-02-04T07:25:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 4, 2011, 7:25am UTC](https://www.ruby-forum.com/t/possible-causes-for-request-time-taking-twice-as-long-as-upstream-response-time/202717/1 "2011-02-04T07:25:02Z")

</div>

Hello,

I am doing some performance analysis for one of our sites.  
In the Nginx access\_log, I record the $request\_time and the  
$upstream\_response\_time.

While looking at these logs I can see that sometimes these numbers have  
a fairly large delta.  
For example one request’s request\_time is 1.553 while the  
upstream\_response\_time is 0.864.

What are some of the potential causes for this large delta and is there  
anything I can do about it?

A few reasons I can think of may be:

- The requester is on a slow internet connection : Not much I can do  
about that

- Nginx is getting too many requests : Add more workers and or more  
Nginx servers

Thanks,

Zev

---

<div class="post-metadata">

**Author:** ![Zev\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb8c5e/32.png) [@Zev\_B](https://www.ruby-forum.com/u/Zev_B)\
**Post date:** [February 29, 2012, 10:39am UTC](https://www.ruby-forum.com/t/possible-causes-for-request-time-taking-twice-as-long-as-upstream-response-time/202717/2 "2012-02-29T10:39:13Z")

</div>

On 02/04/2011 07:23 AM, Zev B. wrote:

> While looking at these logs I can see that sometimes these numbers have a fairly  
> large delta.  
> For example one request’s request\_time is 1.553 while the upstream\_response\_time  
> is 0.864.

Hello, did you find any more info on this ? I was also doing tuning on  
my NGINX setup and I also wondering about this delta.

Regards.

–  
Simone

---

<div class="post-metadata">

**Author:** ![Zev\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb8c5e/32.png) [@Zev\_B](https://www.ruby-forum.com/u/Zev_B)\
**Post date:** [February 29, 2012, 12:29pm UTC](https://www.ruby-forum.com/t/possible-causes-for-request-time-taking-twice-as-long-as-upstream-response-time/202717/3 "2012-02-29T12:29:03Z")

</div>

Hello!

On Wed, Feb 29, 2012 at 10:38:26AM +0100, Simone F. wrote:

> On 02/04/2011 07:23 AM, Zev B. wrote:
> 
> > While looking at these logs I can see that sometimes these numbers have a  
> > fairly large delta.  
> > For example one request’s request\_time is 1.553 while the  
> > upstream\_response\_time is 0.864.
> 
> Hello, did you find any more info on this ? I was also doing  
> tuning on my NGINX setup and I also wondering about this delta.

$request\_time is a total time of request processing, including  
reading request from a client and sending response to the client.

$upstream\_response\_time is a time of obtaining response from an  
upstream server.

The $request\_time variable is expected to be always larger than  
$upstream\_response\_time one as in addition to $upstream\_response\_time  
it also includes at least a) reading request from a client and b)  
sending (buffered part of) the response to the client. Both (a)  
and (b) may take a while.

Maxim D.
