[Varnish] #859: varnish does not process non-cachehigh traffic and waits on them

Varnish varnish-bugs at varnish-cache.org
Thu Feb 10 02:03:34 CET 2011


#859: varnish does not process non-cachehigh traffic and waits on them
-------------------+--------------------------------------------------------
 Reporter:  hyou   |        Type:  defect 
   Status:  new    |    Priority:  highest
Milestone:         |   Component:  build  
  Version:  2.1.2  |    Severity:  blocker
 Keywords:         |  
-------------------+--------------------------------------------------------
 It seems we are receiving more requests at a time than Varnish can handle
 under its configuration which has proven to be non-optimal.

 The requests process fine on apache back-end, and there seems to be no
 stress on the webservers.  However,

 1)  the response getting back to Akamai has 0 byte in content.
 2)  minutes after we stop sending the requests to varnish, varnish is
 still busy processing the the old requests sending them to apache.
 3)  Using JMeter for test, we get 503 errors returned, however on apache
 servers we get 200 success request in logs with some 301s.

 At first, thought the problem can be Keep-alive, but there seems to be no
 place that it gets set.  Sess_timeout by default is 5 sec, correct?
 Anything you think we should change?


 Our setup is Akami ---> Zeus load balancer ---> 2 varnish servers in round
 robin sharing cache ---> 4 apache severs Round Robin ----> Drupal 6



 Here is our config settings:

 Varnish file:

  Configuration file for varnish


 £ Maximum number of open files (for ulimit -n)
 NFILES=131072

 £ Locked shared memory (for ulimit -l)
 £ Default log size is 82MB + header
 MEMLOCK=82000

 DAEMON_OPTS="-a :80 ç
              -T 10.64.74.19:6082 ç
              -f /etc/varnish/default.vcl ç
              -u varnish -g varnish ç
              -s file,/var/lib/varnish/varnish_storage.bin,1G"




 and /etc/varnish/default.vcl contains:


 backend web1 é
 .host = "tv-web1";
 .port = "80";
 .connect_timeout = 600s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 600s;
 è

 backend web2 é
 .host = "tv-web2";
 .port = "80";
 .connect_timeout = 600s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 600s;
 è

 backend web3 é
 .host = "tv-web3";
 .port = "80";
 .connect_timeout = 600s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 600s;
 è

 backend web5 é
 .host = "tv-web5";
 .port = "80";
 .connect_timeout = 600s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 600s;
 è



 director www round-robin é
   é .backend = web1; è
   é .backend = web2; è
   é .backend = web3; è
   é .backend = web5; è
 è

 sub vcl_recv é
 set req.backend = www;

 £ This section will turn off varnish for the whole site but allow us to do
 testing.
   £ Cache things with these extensions
   if (req.url ¨
 "ç.(icoùjsùcssùjpgùjpegùpngùgifùgzùtgzùbz2ùtbzùmp3ùoggùswfùICOùJSùCSSùJPGùJPEGùPNGùGIFùGZùTGZùBZ2ùTBZùMP3ùOOGùSWF)")
 é
     unset req.http.Cookie;
     unset req.http.User-Agent;
     return(lookup);
   è


 £ Set so only www uses varnish
   if (req.http.host ¨ "origin.tv.com") é
     return(pass);
   è
   if (req.http.host ¨ "wwwç.tvç.comùoriginç.wwwç.tvç.com") é

   èelseé
     return(pass);
   è

   if (req.http.User-Agent ¨ "MSIE") é
     set req.http.User-Agent = "MSIE";
   è else é
     set req.http.User-Agent = "Mozilla";
   è

 £ Normalize the host header always to be www.tv.com to reduce cache.  This
 is where we will need to set up Mobile.
   set req.http.host = "www.tv.com";
   remove req.http.X-Forwarded-For;
   set req.http.X-Forwarded-For = client.ip;

   // No varnish for install, update, or cron
   if (req.url ¨
 "ahah_helperç.phpù_pointsç.phpùinstallç.phpùupdateç.phpùcronç.php") é
     return (pass);
   è

   // To users: if you have additional cookies being set by your system
 (e.g.
   // from a javascript analytics file or similar) you will need to add VCL
   // at this point to strip these cookies from the req object, otherwise
   // Varnish will not cache the response. This is safe for cookies that
 your
   // backed (Drupal) doesn't process.
   //
   // Again, the common example is an analytics or other Javascript add-on.
   // You should do this here, before the other cookie stuff, or by adding
   // to the regular-expression above.

  // Remove has_js and Google Analytics __* cookies.
   set req.http.Cookie = regsuball(req.http.Cookie,
 "(^ù;çs*)(__°a-z§+ùhas_js)=°^;§*", "");
   // Remove a ";" prefix, if present.
   set req.http.Cookie = regsub(req.http.Cookie, "^;çs*", "");
   // Remove empty cookies.
   if (req.http.Cookie ¨ "^çs*$") é
     unset req.http.Cookie;
   è




   // Normalize the Accept-Encoding header
   // as per: http://varnish-cache.org/wiki/FAQ/Compression
   if (req.http.Accept-Encoding) é
     if (req.url ¨ "ç.(jpgùpngùgifùgzùtgzùbz2ùtbzùmp3ùogg)$") é
       £ No point in compressing these
       remove req.http.Accept-Encoding;
     è elsif (req.http.Accept-Encoding ¨ "gzip") é
       set req.http.Accept-Encoding = "gzip";
    è elsif (req.http.Accept-Encoding ¨ "deflate") é
       set req.http.Accept-Encoding = "deflate";
     è else é
       £ unkown algorithm
       remove req.http.Accept-Encoding;
     è
   è

 £ This lets post requests go through because those may need cookies.
   if (req.request != "GET" && req.request != "HEAD") é
    return (pass);
   è

   // Let's have a little grace
   set req.grace = 30s;

 £ We are unsetting the cookies otherwise no drupal page will cache
 properly.  We try to set these back in vcl_miss not sure it's working
 though.
   set req.http.OLD-Cookie = req.http.Cookie;
   unset req.http.Cookie;

   return(lookup);
 è

 sub vcl_miss é
   if (req.url ¨
 "ç.(icoùjsùcssùjpgùjpegùpngùgifùgzùtgzùbz2ùtbzùmp3ùoggùswfùICOùJSùCSSùJPGùJPEGùPNGùGIFùGZùTGZùBZ2ùTBZùMP3ùOOGùSWF)")
 é

   è else é
     if (req.http.OLD-Cookie) é
       set bereq.http.Cookie = req.http.OLD-Cookie;
       unset req.http.OLD-Cookie;
     è
   è
   return (fetch);
 è

 sub vcl_hit é
   if (req.http.Cache-Control ¨ "no-cache") é
     £ Ignore requests via proxy caches,  IE users and badly behaved
 crawlers
     £ like msnbot that send no-cache with every request.
     if (! (req.http.Via ùù req.http.User-Agent ¨ "botùMSIE")) é
       set obj.ttl = 0s;
       return (restart);
     è
   è
 è

 // Strip any cookies before an image/js/css is inserted into cache.
 // Also: future-support for ESI.
 sub vcl_fetch é
   // Varnish determined the object was not cacheable
   if (!beresp.cacheable) é
     set beresp.http.Varnish-X-Cacheable = "NO:Not Cacheable";
     set beresp.http.storage = "1";
     return(deliver);

   è


 £ Check for no-store header and deliver if it exists.
   if (beresp.http.Edge-control ¨ "no-store")é
     set beresp.http.storage = "1";
     set beresp.cacheable = false;
     return(deliver);
   è

 £ Cache things with these extensions
   if (bereq.url ¨
 "ç.(icoùjsùcssùjpgùjpegùpngùgifùgzùtgzùbz2ùtbzùmp3ùoggùswfùICOùJSùCSSùJPGùJPEGùPNGùGIFùGZùTGZùBZ2ùTBZùMP3ùOOGùSWF)")
 é
     unset beresp.http.set-cookie;

     /* Remove Expires from backend, it's not long enough */
     unset beresp.http.expires;

     /* Set the clients TTL on this object */
     set beresp.http.static = "true";
     /* Set how long Varnish will keep it */
     set beresp.ttl = 1d;
     return(deliver);
   è

     unset beresp.http.set-cookie;
     unset beresp.http.expires;
     unset beresp.http.Cookie;

     /* Set how long Varnish will keep it */
     set beresp.ttl = 1d;

   return (deliver);
 è

 sub vcl_deliver é
    £add cache hit data
    if (obj.hits > 0) é
      £if hit add hit count
      set resp.http.Varnish-X-Cache = "HIT";
      set resp.http.Vanrish-X-Cache-Hits = obj.hits;
    è else é
      set resp.http.Varnish-X-Cache = "MISS";
    è

 è

 sub vcl_hash é

   if (req.http.Cookie) é
     //set req.hash += req.http.Cookie;
   è
 è

 sub vcl_error é
   // Let's deliver a slightly more friedly error page.
   // You can customize this as you wish.
   set obj.http.Content-Type = "text/html; charset=utf-8";
   synthetic é"
   <?xml version="1.0" encoding="utf-8"?>
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   <html>
     <head>
       <title>"è obj.status " " obj.response é"</title>
       <style type="text/css">
       £page éwidth: 400px; padding: 10px; margin: 20px auto; border: 1px
 solid black; background-color: £FFF;è
       p émargin-left:20px;è
       body ébackground-color: £DDD; margin: auto;è
       </style>
     </head>
     <body>
     <div id="page">
     <h1>Page Could Not Be Loaded</h1>
     <p>We're very sorry, but the page could not be loaded properly. This
 should be fixed very soon, and we apologize for any inconvenience.</p>
     <hr />
     <h4>Debug Info:</h4>
     <pre>
 Status: "è obj.status é"
 Response: "è obj.response é"
 XID: "è req.xid é"
 </pre>
       <address><a href="http://www.varnish-
 cache.org/">Varnish</a></address>
       </div>
     </body>
    </html>
    "è;
    return (deliver);

-- 
Ticket URL: <http://www.varnish-cache.org/trac/ticket/859>
Varnish <http://varnish-cache.org/>
The Varnish HTTP Accelerator




More information about the varnish-bugs mailing list