Varnish appears to hang/requests time out

Martin Aspeli optilude at gmx.net
Wed Aug 29 09:29:51 CEST 2007


Martin Aspeli wrote:
> Hi guys,
> 
> I'm having some trouble with Varnish 1.1.1 tarball and 1.1 branch in svn 
> (r1922), and trunk as of today.
> 
> Basically, I use a setup where I have Apache with virtual hosting, in 
> front of Varnish (VCL included) in front of Zope/Plone (Plone 3 with 
> CacheFu 1.1, in case that means anything to you, it hopefully shouldn't 
> matter).
> 
> It's hard to debug, but Varnish appears to hang, in that requests never 
> complete. Not always, but between five or ten requests, I can make a few 
> do this.
> 
> I can't spot an obvious pattern, but it's normally either a page or a JS 
> or CSS request. It happens sometimes on basic GET requests, and more 
> often on POST requests.
> 
> Is this familiar to anyone? Can I do anything more useful to debug?

After more testing - I know of at least one, probably two other people 
who've had the same problem with the 1.1 branch (and 1.1 final, and 
1.1.1 final, and trunk). They, like me, have reverted to 1.0 final, 
which seems a lot more stable in this regard. I'm pasting the VCL I use 
for 1.0, but it's not much difference.

Are people using 1.1.1 in production? Am I missing something in my 
configuration? How can I debug this better?

Cheers,
Martin

Varnish 1.0 config that works:
------------------------------

backend default_backend {
	set backend.host = "127.0.0.1";
	set backend.port = "8080";
}

acl purge {
	"localhost";
}

sub vcl_recv {

	if (req.request != "GET" && req.request != "HEAD") {
         	# PURGE request if zope asks nicely
         	if (req.request == "PURGE") {
         	        if (!client.ip ~ purge) {
         	                error 405 "Not allowed.";
         	        }
         	        lookup;
         	}
		pipe;
	}
	if (req.http.Expect) {
		pipe;
	}

	/* Always cache images */
	if (req.url ~ 
"\.(jpg|jpeg|gif|png|tiff|tif|svg|swf|ico|css|js|vsd|doc|ppt|pps|xls|pdf|mp3|mp4|m4a|ogg|mov|avi|wmv|sxw|zip|gz|bz2|tgz|tar|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$") 
{
		lookup;
	}
	/* Always cache CSS and javascript */
	if (req.url ~ "\.(css|js)$") {
		lookup;
	}

	/* Do not cache other authorised content */
	if (req.http.Authenticate || req.http.Authorization) {
		pass;
	}
	# We only care about the "__ac.*" cookies, used for authentication
	if (req.http.Cookie && req.http.Cookie ~ 
"__ac(|_(name|password|persistent))=") {
		pass;
	}
# XXX Add a check for _ZopeId here as well so we do not cache requests which
# rely on Zope sessions
	lookup;
}

# Do the PURGE thing
sub vcl_hit {
         if (req.request == "PURGE") {
                 set obj.ttl = 0s;
                 error 200 "Purged";
         }
}
sub vcl_miss {
         if (req.request == "PURGE") {
                 error 404 "Not in cache";
         }
}


sub vcl_fetch {
	if (!obj.valid) {
		error;
	}
	if (!obj.cacheable) {
		pass;
	}
	if (resp.http.Set-Cookie) {
		pass;
	}

	if (req.url ~ "(rss_|search_rss)") {
		set obj.ttl = 1800s;
	}
}

For comparison, 1.1 config that doesn't work:
---------------------------------------------

backend backend_0 {
      set backend.host = "127.0.0.1";
      set backend.port = "8080";
}



acl purge {
      "localhost";
}

sub vcl_recv {


      if (req.request == "PURGE") {
          if (!client.ip ~ purge) {
                  error 405 "Not allowed.";
          }
          lookup;
      }

      if (req.request != "GET" && req.request != "HEAD") {
          # Do not try to cache POST
	pipe;
      }

      if (req.http.Expect) {
          pipe;
      }

      if (req.http.If-None-Match) {
          pass;
      }

      /* Always cache images and binaries */
      if (req.url ~
"\.(jpg|jpeg|gif|png|tiff|tif|svg|swf|ico|vsd|doc|ppt|pps|xls|pdf|mp3|mp4|m4a|ogg|mov|avi|wmv|sxw|zip|gz|bz2|tgz|tar|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$") 

{
          lookup;
      }
      /* Always cache CSS and javascript */
      if (req.url ~ "\.(css|js)$") {
          lookup;
      }

      /* Do not cache other authorised content */
      if (req.http.Authenticate || req.http.Authorization) {
          pass;
      }

      /* We only care about the "__ac.*" cookies, used for authentication */
      if (req.http.Cookie && (req.http.Cookie ~
"__ac(_(name|password|persistent))?=" || req.http.Cookie ~ "_ZopeId")) {
          pass;
      }

      lookup;
}

/* Deal with purge requests */
sub vcl_hit {
      if (req.request == "PURGE") {
              set obj.ttl = 0s;
              error 200 "Purged";
      }
}

sub vcl_miss {
      if (req.http.If-Modified-Since) {
          pass;
      }

      if (req.request == "PURGE") {
              error 404 "Not in cache";
      }
}

sub vcl_fetch {
      if (!obj.valid) {
          error;
      }
      if (!obj.cacheable) {
          pass;
      }
      if (obj.http.Set-Cookie) {
          pass;
      }

      if (req.url ~ "(rss_|search_rss)") {
          set obj.ttl = 1800s;
      }
}

-- 
Acquisition is a jealous mistress




More information about the varnish-misc mailing list