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

Tyler Kovacs tyler.kovacs at
Mon Apr 21 00:21:34 MSD 2008

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:

  <!--# include virtual="/fragment/1" -->
  <!--# include virtual="/fragment/2" -->

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?  

More information about the nginx mailing list