Nginx hangs on page with multiple virtual ssi tags that hit memcache

I have discovered a situation where nginx consistently hangs when
interacting
with memcached while using multiple SSI virtual tags in a single page.
Our
application returns a page that looks like this:

nginx is configured to serve local files, then fallback to memcache then
fallback to my upstream app (Rails) like this:

location / {
error_page 404 = @memcache;
}

location @memcache {
set $memcached_key “nginx:$uri?$args”;
memcached_pass localhost:11212;
default_type text/html;
error_page 404 502 = @fallback;
}

location @fallback {
ssi on;
proxy_pass http://zvents;
}

nginx returns the page and then attempts to process the SSI virtual
tags. If
the page has multiple virtual SSI and they are not set to wait then
nginx hangs
when trying to talk to memcached. Sometimes the first few requests are
successful but it doesn’t take long for nginx to lock up. nginx does
not lock
up under any of these conditions:

  • there’s only 1 SSI virtual on the page
  • there’s multiple SSI virtual but each is set wait=“yes”
  • memcached is not running or the memcache requests are cache misses

I have tested with nginx 0.5.32, 0.5.35 and 0.6.29 with memcached 1.2.2
and
1.2.5 - it happens with each combination.

Has anyone else seen this?

This post was a life saver. I’ve used wait=yes option and that has
helped remedy my ‘hang’ as well .

Thank god for ruby-talk.
Here’s an awesome link as well, with other ssi methods/gotcha’s -

http://wiki.codemongers.com/NginxHttpSsiModule

Thanks again!

Tyler K. wrote:

I have discovered a situation where nginx consistently hangs when
interacting
with memcached while using multiple SSI virtual tags in a single page.
Our
nginx returns the page and then attempts to process the SSI virtual
tags. If
the page has multiple virtual SSI and they are not set to wait then
nginx hangs
when trying to talk to memcached. Sometimes the first few requests are
successful but it doesn’t take long for nginx to lock up. nginx does
not lock
up under any of these conditions:

  • there’s only 1 SSI virtual on the page
  • there’s multiple SSI virtual but each is set wait=“yes”
  • memcached is not running or the memcache requests are cache misses

I have tested with nginx 0.5.32, 0.5.35 and 0.6.29 with memcached 1.2.2
and
1.2.5 - it happens with each combination.

Has anyone else seen this?