Hi list, <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> worker_connections 8192;</div><div> use epoll;</div><div>}</div><div><br></div><div>http {</div><div> include /etc/nginx/mime.types;</div><div> default_type application/octet-stream;</div>
<div><br></div><div> log_format main</div><div> '$remote_addr - $remote_user [$time_local] '</div><div> '"$request" $status $bytes_sent '</div><div> '"$http_referer" "$http_user_agent" '</div>
<div> '"$gzip_ratio"';</div><div><br></div><div><br></div><div> client_max_body_size 10m;</div><div> client_body_buffer_size 256k;</div><div> proxy_connect_timeout 90;</div><div>
proxy_send_timeout 90;</div><div> proxy_read_timeout 90;</div><div> proxy_buffer_size 4k;</div><div> proxy_buffers 10 32k;</div><div> proxy_busy_buffers_size 64k;</div>
<div><div> proxy_temp_file_write_size 64k;</div><div><br></div><div> upstream backend{</div><div> server <a href="http://192.168.172.254:3128" target="_blank">192.168.172.254:3128</a>;</div><div> }</div><div>
<br></div><div>
server {</div><div> listen <a href="http://127.0.0.1:8888" target="_blank">127.0.0.1:8888</a>;</div><div> server_name localhost;</div><div><br></div><div> access_log /var/log/nginx/localhost.access_log main;</div>
<div> error_log /var/log/nginx/localhost.error_log debug;</div><div> proxy_temp_path /cache/temp;</div><div> root /cache/$host;</div><div><br></div><div> location / {</div><div> index index.shtml;</div>
<div> error_page 404 = /fetch$uri;</div><div> }</div><div> location /fetch{</div><div> internal;</div><div> proxy_pass <a href="http://backend" target="_blank">http://backend</a>;</div><div>
proxy_store on;</div>
<div> proxy_store_access user:rw group:rw all:rw;</div><div> proxy_set_header Host $host;</div><div> proxy_set_header X-Real_IP $remote_addr;</div><div> proxy_set_header Via "pahud/nginx";</div>
<div> #proxy_buffering off;</div><div> alias /cache/$host;</div><div><div> }</div><div><br></div><div> }</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>* Trying 127.0.0.1... connected</div><div>* Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0)</div><div>> 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>> User-Agent: curl/7.18.2 (i686-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3</div><div>> Host: <a href="http://farm4.static.flickr.com" target="_blank">farm4.static.flickr.com</a></div><div>> Pragma: no-cache</div>
<div>> Accept: */*</div><div>> Proxy-Connection: Keep-Alive</div><div>></div><div>< HTTP/1.1 200 OK</div><div>< Server: nginx/0.7.30</div><div>< Date: Mon, 29 Dec 2008 07:24:10 GMT</div><div>< Content-Type: image/jpeg</div>
<div>< Connection: keep-alive</div><div>< Last-Modified: Sun, 28 Dec 2008 13:32:53 GMT</div><div>< Accept-Ranges: bytes</div><div>< Content-Length: 165659</div><div>< Expires: Mon, 28 Jul 2014 23:30:00 GMT</div>
<div>< Cache-Control: max-age=315360000</div><div>< X-Cache: HIT from <a href="http://photocache416.flickr.gq1.yahoo.com" target="_blank">photocache416.flickr.gq1.yahoo.com</a></div><div>< 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>< X-Cache: MISS from gateway.office</div><div>< 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><</div><div><div>{ [data not shown]</div><div> % Total % Received % Xferd Average Speed Time Time Time Current</div><div> Dload Upload Total Spent Left Speed</div>
<div>100 161k 100 161k 0 0 2695 0 0:01:01 0:01:01 --:--:-- 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 1m1.462s</div>
<div>user 0m0.000s</div><div>sys 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>* Trying 192.168.172.254... connected</div><div>* Connected to 192.168.172.254 (192.168.172.254) port 3128 (#0)</div><div>> 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>> User-Agent: curl/7.18.2 (i686-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3</div><div>> Host: <a href="http://farm4.static.flickr.com" target="_blank">farm4.static.flickr.com</a></div><div>> Pragma: no-cache</div>
<div>> Accept: */*</div><div>> Proxy-Connection: Keep-Alive</div><div>></div><div>* HTTP 1.0, assume close after body</div><div>< HTTP/1.0 200 OK</div><div>< Last-Modified: Sun, 28 Dec 2008 13:32:53 GMT</div>
<div>< Accept-Ranges: bytes</div><div>< Content-Length: 165659</div><div>< Content-Type: image/jpeg</div><div>< Date: Mon, 29 Dec 2008 07:26:42 GMT</div><div>< Server: Apache/2.0.52 (Red Hat)</div><div>< Expires: Mon, 28 Jul 2014 23:30:00 GMT</div>
<div>< Cache-Control: max-age=315360000</div><div>< X-Cache: HIT from <a href="http://photocache416.flickr.gq1.yahoo.com" target="_blank">photocache416.flickr.gq1.yahoo.com</a></div><div>< 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>< X-Cache: MISS from gateway.office</div><div>< 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>< Proxy-Connection: keep-alive</div><div><</div><div>{ [data not shown]</div><div> % Total % Received % Xferd Average Speed Time Time Time Current</div>
<div> Dload Upload Total Spent Left Speed</div><div>100 161k 100 161k 0 0 25465 0 0:00:06 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 0m6.514s</div><div>user 0m0.000s</div><div>sys 0m0.000s</div><div><br></div><div><br></div><div>Only 6 seconds!! </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>