Varnish returns 503 error.

Abraham Cruz Sustaita abraham.sustaita at buscacorp.com
Wed Jun 13 22:24:42 CEST 2012


I'm using varnish to cache the content of my websites. It is working as it
supposed, but there is a problem. Randomly it returns an 503 error, it is
really strange, since the app servers are ok and the load is under .8, also
the database server its ok. Here is part of my configuration:

backend app05 {
  .host = "app05.site.com";
  .port = "80";
  .connect_timeout = 0.7s;
  .first_byte_timeout = 30s;
  .between_bytes_timeout = 30s;
  .probe = {
    .url = "/";
    .interval = 5s;
    .timeout = 1s;
    .window = 5;
    .threshold = 3;
  }
}

director app_director round-robin {
  { .backend = app01; }
  { .backend = app02; }
  { .backend = app03; }
  { .backend = app04; }
  { .backend = app05; }
}

sub vcl_fetch {

  # remove all cookies
  # unset beresp.http.set-cookie;

  # cache for 12 hours
  # set beresp.ttl = 2h;

  # Don't allow static files to set cookies.
  if (req.url ~
"(?i)\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|mp4|flv)(\?[a-z0-9]+)?$") {
    unset beresp.http.set-cookie;
    set beresp.ttl = 12h;
  } else {
    set beresp.ttl = 30m;
  }

  # If the backend server doesn't return properly, don't send another
connection to it
  # for 60s and try another backend via restart.
  #
  #
https://www.varnish-cache.org/docs/trunk/tutorial/handling_misbehaving_servers.html
  # --
  if(beresp.status == 500 || beresp.status == 503) {
    set beresp.saintmode = 5m;
    if (req.request != "POST") {
*      return(restart); # Here is the configuration to restart the
connection if a server returns a 503 error, but it is not working*
    } else {
      error 500 "Failed";
    }
  }

  # Allow items to be stale if needed.
  set beresp.grace = 1h;

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20120613/8cb5bee0/attachment.html>


More information about the varnish-misc mailing list