2

ワニスを使用して、Web サイトのコンテンツをキャッシュしています。想定どおりに動作していますが、問題があります。ランダムに 503 エラーが返されます。これは非常に奇妙です。アプリケーション サーバーは問題なく、負荷は 0.8 未満であり、データベース サーバーも問題ないためです。これが私の構成の一部です:

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) {
    set beresp.saintmode = 5m;
    if (req.request != "POST") {
      return(restart);
    } else {
      error 500 "Failed";
    }
  }

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

}

if beresp.status == 503 にも追加する必要がありますか?

4

1 に答える 1

4

これを修正しました。接続が切れる時間を増やして、再接続の回数を確認するだけで済みました。追加した行は次のとおりです。

host = "app01.site.com";
  .port = "80";
  .connect_timeout = 1.5s;
  .first_byte_timeout = 45s;
  .between_bytes_timeout = 30s;

if (req.restarts > 3) {
  set beresp.saintmode = 5m;
}
于 2012-07-02T18:39:19.870 に答える