Hi list,&nbsp;<div class="gmail_quote"><div><br></div><div>this is my config</div><div><br></div><div>----------------------------</div><div><br></div><div><div>user nginx nginx;</div><div>worker_processes 8;</div><div><br></div>
<div>error_log /var/log/nginx/error_log info;</div>
<div><br></div><div>events {</div><div>&nbsp;&nbsp; worker_connections &nbsp;8192;</div><div>&nbsp;&nbsp; use epoll;</div><div>}</div><div><br></div><div>http {</div><div>&nbsp;&nbsp; include &nbsp; &nbsp; /etc/nginx/mime.types;</div><div>&nbsp;&nbsp; default_type &nbsp; application/octet-stream;</div>

<div><br></div><div>&nbsp;&nbsp; log_format main</div><div>&nbsp;&nbsp; &nbsp; &nbsp;&#39;$remote_addr - $remote_user [$time_local] &#39;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &#39;&quot;$request&quot; $status $bytes_sent &#39;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;&#39;&quot;$http_referer&quot; &quot;$http_user_agent&quot; &#39;</div>

<div>&nbsp;&nbsp; &nbsp; &nbsp;&#39;&quot;$gzip_ratio&quot;&#39;;</div><div><br></div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;client_max_body_size &nbsp; &nbsp;10m;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; client_body_buffer_size 256k;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; proxy_connect_timeout &nbsp;90;</div><div>

&nbsp;&nbsp; &nbsp; &nbsp; proxy_send_timeout &nbsp; &nbsp; &nbsp;90;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; proxy_read_timeout &nbsp; &nbsp; &nbsp;90;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; proxy_buffer_size &nbsp; &nbsp; &nbsp;4k;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; proxy_buffers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10 32k;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; proxy_busy_buffers_size 64k;</div>

<div><div>&nbsp;&nbsp; &nbsp; &nbsp; proxy_temp_file_write_size 64k;</div><div><br></div><div>&nbsp;&nbsp; upstream backend{</div><div>&nbsp;&nbsp; &nbsp; &nbsp;server <a href="http://192.168.172.254:3128" target="_blank">192.168.172.254:3128</a>;</div><div>&nbsp;&nbsp; }</div><div>
<br></div><div>
&nbsp;&nbsp; server {</div><div>&nbsp;&nbsp; &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp;<a href="http://127.0.0.1:8888" target="_blank">127.0.0.1:8888</a>;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;server_name localhost;</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;access_log &nbsp;/var/log/nginx/localhost.access_log main;</div>

<div>&nbsp;&nbsp; &nbsp; &nbsp;error_log &nbsp; /var/log/nginx/localhost.error_log debug;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;proxy_temp_path &nbsp; /cache/temp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;root &nbsp;/cache/$host;</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;location / {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; index index.shtml;</div>

<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; error_page 404 = /fetch$uri;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp;location /fetch{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; internal;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; proxy_pass <a href="http://backend" target="_blank">http://backend</a>;</div><div>
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; proxy_store on;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; proxy_store_access user:rw group:rw all:rw;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; proxy_set_header Host $host;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; proxy_set_header X-Real_IP $remote_addr;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; proxy_set_header Via &quot;pahud/nginx&quot;;</div>

<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; #proxy_buffering off;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; alias /cache/$host;</div><div><div>&nbsp;&nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; }</div><div><br></div><div>}</div><div><br></div><div>----------------------------<br></div><div>

<br></div><div><br></div><div>so nginx is listening on localhost:8888 and when trying to fetch a missing jpg it goes to upstream proxy to fetch it. So I made a try here:</div><div><br></div><div><div>pahud@gentoo-9 ~ $[15:24:07] time curl -L -v <a href="http://farm4.static.flickr.com/3081/3144192428_7dcf9da972.jpg" target="_blank">http://farm4.static.flickr.com/3081/3144192428_7dcf9da972.jpg</a> -x <a href="http://127.0.0.1:8888" target="_blank">127.0.0.1:8888</a> -o /dev/null</div>

<div>* About to connect() to proxy 127.0.0.1 port 8888 (#0)</div><div>* &nbsp; Trying 127.0.0.1... connected</div><div>* Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0)</div><div>&gt; GET <a href="http://farm4.static.flickr.com/3081/3144192428_7dcf9da972.jpg" target="_blank">http://farm4.static.flickr.com/3081/3144192428_7dcf9da972.jpg</a> HTTP/1.1</div>

<div>&gt; User-Agent: curl/7.18.2 (i686-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3</div><div>&gt; Host: <a href="http://farm4.static.flickr.com" target="_blank">farm4.static.flickr.com</a></div><div>&gt; Pragma: no-cache</div>

<div>&gt; Accept: */*</div><div>&gt; Proxy-Connection: Keep-Alive</div><div>&gt;</div><div>&lt; HTTP/1.1 200 OK</div><div>&lt; Server: nginx/0.7.30</div><div>&lt; Date: Mon, 29 Dec 2008 07:24:10 GMT</div><div>&lt; Content-Type: image/jpeg</div>

<div>&lt; Connection: keep-alive</div><div>&lt; Last-Modified: Sun, 28 Dec 2008 13:32:53 GMT</div><div>&lt; Accept-Ranges: bytes</div><div>&lt; Content-Length: 165659</div><div>&lt; Expires: Mon, 28 Jul 2014 23:30:00 GMT</div>

<div>&lt; Cache-Control: max-age=315360000</div><div>&lt; X-Cache: HIT from <a href="http://photocache416.flickr.gq1.yahoo.com" target="_blank">photocache416.flickr.gq1.yahoo.com</a></div><div>&lt; X-Cache-Lookup: HIT from <a href="http://photocache416.flickr.gq1.yahoo.com:80" target="_blank">photocache416.flickr.gq1.yahoo.com:80</a></div>

<div>&lt; X-Cache: MISS from gateway.office</div><div>&lt; Via: 1.1 <a href="http://photocache416.flickr.gq1.yahoo.com:80" target="_blank">photocache416.flickr.gq1.yahoo.com:80</a> (squid/2.7.STABLE2), 1.0 gateway.office:3128 (squid/2.6.STABLE12)</div>

<div>&lt;</div><div><div>{ [data not shown]</div><div>&nbsp;&nbsp;% Total &nbsp; &nbsp;% Received % Xferd &nbsp;Average Speed &nbsp; Time &nbsp; &nbsp;Time &nbsp; &nbsp; Time &nbsp;Current</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dload &nbsp;Upload &nbsp; Total &nbsp; Spent &nbsp; &nbsp;Left &nbsp;Speed</div>

<div>100 &nbsp;161k &nbsp;100 &nbsp;161k &nbsp; &nbsp;0 &nbsp; &nbsp; 0 &nbsp; 2695 &nbsp; &nbsp; &nbsp;0 &nbsp;0:01:01 &nbsp;0:01:01 --:--:-- &nbsp;3893* Connection #0 to host 127.0.0.1 left intact</div><div><br></div><div>* Closing connection #0</div><div><br></div><div>real &nbsp; &nbsp;1m1.462s</div>

<div>user &nbsp; &nbsp;0m0.000s</div><div>sys &nbsp; &nbsp; 0m0.004s</div><div><br></div><div><br></div><div>Well, it took 1m 1.462s to complete. But if I directly fetch from my upstream server:</div><div><br></div><div><div>pahud@gentoo-9 ~ $[15:26:26] time curl -L -v <a href="http://farm4.static.flickr.com/3081/3144192428_7dcf9da972.jpg" target="_blank">http://farm4.static.flickr.com/3081/3144192428_7dcf9da972.jpg</a> -x <a href="http://192.168.172.254:3128" target="_blank">192.168.172.254:3128</a> -o /dev/null</div>

<div>* About to connect() to proxy 192.168.172.254 port 3128 (#0)</div><div>* &nbsp; Trying 192.168.172.254... connected</div><div>* Connected to 192.168.172.254 (192.168.172.254) port 3128 (#0)</div><div>&gt; GET <a href="http://farm4.static.flickr.com/3081/3144192428_7dcf9da972.jpg" target="_blank">http://farm4.static.flickr.com/3081/3144192428_7dcf9da972.jpg</a> HTTP/1.1</div>

<div>&gt; User-Agent: curl/7.18.2 (i686-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3</div><div>&gt; Host: <a href="http://farm4.static.flickr.com" target="_blank">farm4.static.flickr.com</a></div><div>&gt; Pragma: no-cache</div>

<div>&gt; Accept: */*</div><div>&gt; Proxy-Connection: Keep-Alive</div><div>&gt;</div><div>* HTTP 1.0, assume close after body</div><div>&lt; HTTP/1.0 200 OK</div><div>&lt; Last-Modified: Sun, 28 Dec 2008 13:32:53 GMT</div>

<div>&lt; Accept-Ranges: bytes</div><div>&lt; Content-Length: 165659</div><div>&lt; Content-Type: image/jpeg</div><div>&lt; Date: Mon, 29 Dec 2008 07:26:42 GMT</div><div>&lt; Server: Apache/2.0.52 (Red Hat)</div><div>&lt; Expires: Mon, 28 Jul 2014 23:30:00 GMT</div>

<div>&lt; Cache-Control: max-age=315360000</div><div>&lt; X-Cache: HIT from <a href="http://photocache416.flickr.gq1.yahoo.com" target="_blank">photocache416.flickr.gq1.yahoo.com</a></div><div>&lt; X-Cache-Lookup: HIT from <a href="http://photocache416.flickr.gq1.yahoo.com:80" target="_blank">photocache416.flickr.gq1.yahoo.com:80</a></div>

<div>&lt; X-Cache: MISS from gateway.office</div><div>&lt; Via: 1.1 <a href="http://photocache416.flickr.gq1.yahoo.com:80" target="_blank">photocache416.flickr.gq1.yahoo.com:80</a> (squid/2.7.STABLE2), 1.0 gateway.office:3128 (squid/2.6.STABLE12)</div>

<div>* HTTP/1.0 proxy connection set to keep alive!</div><div>&lt; Proxy-Connection: keep-alive</div><div>&lt;</div><div>{ [data not shown]</div><div>&nbsp;&nbsp;% Total &nbsp; &nbsp;% Received % Xferd &nbsp;Average Speed &nbsp; Time &nbsp; &nbsp;Time &nbsp; &nbsp; Time &nbsp;Current</div>

<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dload &nbsp;Upload &nbsp; Total &nbsp; Spent &nbsp; &nbsp;Left &nbsp;Speed</div><div>100 &nbsp;161k &nbsp;100 &nbsp;161k &nbsp; &nbsp;0 &nbsp; &nbsp; 0 &nbsp;25465 &nbsp; &nbsp; &nbsp;0 &nbsp;0:00:06 &nbsp;0:00:06 --:--:-- 34140* Connection #0 to host 192.168.172.254 left intact</div>

<div><br></div><div>* Closing connection #0</div><div><br></div><div>real &nbsp; &nbsp;0m6.514s</div><div>user &nbsp; &nbsp;0m0.000s</div><div>sys &nbsp; &nbsp; 0m0.000s</div><div><br></div><div><br></div><div>Only 6 seconds!!&nbsp;</div></div><div><br></div>

<div>Can someone tell me how can I find the bottleneck?</div><div><br></div><div>pahud</div><div><br></div></div><div><br></div></div><div><br></div></div></div></div>
</div><br>