Welcome! Log In Create A New Profile

Advanced

Nginx proxy_pass + 10mbit traffic with syn, cache only image

Taras Girnyk
March 10, 2010 12:24PM
Hi, communtiy.

Maybe you can help solve my problem.
I'm using nginx to proxify different request to dozens of backends.

I encountered such problem:
If I enable caching in nginx, during high incoming requests (it seems
~100 req/sec) some responses failed to cache (more often it's css
styles, which i can easily see is missing)

I suppose this is due to following reason:
Request goes to the backend, but due to high network load response from
backend lost somewhere in timeouts or network buffers in kernel. Then,
when another requests comes, nginx think, it have this file cached on
hdd, but fails and returns blank response. That causes some images and
styles from webpages to disappear.

This is a part from global conf file which i believe can influence on
this:

client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
large_client_header_buffers 40 20k;
output_buffers 1 32k;
postpone_output 1460;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 0;
reset_timedout_connection on;

Any my proxy location looks like
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_header Set-Cookie;
proxy_pass_header P3P;
proxy_pass http://@PROXY_IP@/
}

After this i thought: ok, it would be nice to cache only that images and
proxify all other request direct to backend, but how should i configure
cache to store only image files, to be sure to avoid any caching of
dynamic pages and problems with such items like cached shopping cart or
cached dynamic information on home page?

I've tried to install different location like ~ .+(.jpg|jpeg) and so on,
but conftest failed with reason "i can't do proxy pass in location,
which contains regexp". I found a solution with proxy_store
/tmp$original_uri and then with handling error_page 404 to some other
location with proxy pass to backend somewhere on this forum, or on
Igor's website. But it seems to me, this is not the best solution. First
of all i aware of cycling "error 404" request if this image are not
avaible even on backend. Also, it seems this is not the direct way to
cache static files.

Thank you.
--
Posted via http://www.ruby-forum.com/.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nginx proxy_pass + 10mbit traffic with syn, cache only image

Taras Girnyk March 10, 2010 12:24PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 300
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready