Nginx (PPA stable) periodically returning headers then hanging connection when serving from fcgi cac

List,

I’m experiencing some problems with FastCGI cache and nginx/1.0.4 from
stable PPA on Ubuntu Lucid.

In short, it seems that sometimes the FastCGI cache is getting corrupted
somehow - Nginx will serve sane headers from cache, but then the
connection will seem to hang, with no body returned until the request is
timed out by the client (apparently it’ll hang indefinitely).

For example, headers will appear good:

HTTP/1.1 200 OK
Server: nginx
X-Cache-Status: HIT
Cache-Control: public, max_age=300
Content-Type: text/html; charset=utf-8
Date: Thu, 17 Nov 2011 09:58:26 GMT
Expires: Thu, 17 Nov 2011 10:02:46
Etag: 611a2b5dcde004cf68ffd56345584d40
Connection: close
Last-Modified: Thu, 17 Nov 2011 09:57:46
Transfer-Encoding: Identity

but then the connection sits there without returning the body.

Once nginx returns one “bad” response (as described above), all
subsequent requests for the same (cached) resource have the same
problem. Other cached resources seem to work as normal, and have
experienced it twice in the past 24 hours.

The only resolution I’ve found so far is to junk my cache folder and
bounce the nginx service.

Here’s what my vhost config looks like:

server {

listen 80 default;
server_name example.com;

server_tokens off;

root /home/user/example.com/web;
index index.php;

access_log /dev/null;
error_log /var/log/nginx/error.log;

location / {

if (-f $request_filename) {
  expires 3h;
  break;
}

rewrite ^(.*) /index.php last;

}

location ~ (.*.php)($|/) {
set $script $1;
set $path_info “”;

if ($uri ~ "^(.+\.php)(/.+)") {
    set  $script   $1;
    set  $path_info  $2;
}

fastcgi_pass 127.0.0.1:9000;


include     fastcgi_params;
fastcgi_read_timeout 180;
fastcgi_param   PATH_INFO $path_info;
fastcgi_param   SCRIPT_FILENAME $document_root$script;
fastcgi_param   SCRIPT_NAME $script;

fastcgi_pass_header  Set-Cookie;

fastcgi_cache_methods GET HEAD;
fastcgi_cache fcgi-cache;
fastcgi_cache_key canimationlive$request_uri;
fastcgi_cache_valid 200 1h;
fastcgi_cache_min_uses 1;
fastcgi_cache_use_stale error timeout http_500 updating;

add_header X-Cache-Status $upstream_cache_status;

}
}

–end

Here’s what the fcgi-cache definition looks like:

fastcgi_cache_path /var/www/cache levels=1:2
keys_zone=fcgi-cache:10m
max_size=512m
inactive=28d;

I’ve just upgraded to nginx 1.0.9 (also from PPA), and noticed in the
changelog for versions 1.0.4 and 1.0.5 a “Bugfix: “stalled cache
updating” alert” - is this the same problem? If so, the above may well
be null and void.

Thanks in advance,

Ben

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs