LoginSignup
0
0

More than 1 year has passed since last update.

Varnish複数オリジン利用時のヘルスチェック

Last updated at Posted at 2021-11-26

本項はLumen Edge Application DeliveryでのVarnishについての記述です

ヘルスチェック(Health checks)

複数のオリジンサーバを用いて冗長化構成を取る際、CloudfrontなどではOrigin Connection Attemptsというリトライ回数指定条件がありますが、Varnishではヘルくチェックを用いて判断を行います:

VCL
backend server1 {
    .host = "server1.example.com";
    .probe = {
        .url = "/";
        .timeout = 1s;
        .interval = 5s;
        .window = 5;
        .threshold = 3;
    }
}

backend server2 {
    .host = "server2.example.com";
    .probe = {
        .url = "/";
        .timeout = 1s;
        .interval = 5s;
        .window = 5;
        .threshold = 3;
    }
}

上記の場合
.url = "/"; TOPディレクトリに対してポーリング(GET)を行う
.timeout = 1s; タイムアウトは1秒
.interval = 5s; 5秒おきにオリジン側にヘルスチェック

そして下記が発動条件となります

.window = 5; 5回のポーリングGETのうち
.threshold = 3; 3回OKであればサーバは活動中とする、それ以下であればNG

という事になります。

次に‘director’設定を行い死活監視NGとなった場合にはトラフィックを送らないという設定を行います:

VCL
sub vcl_init {
    new vdir = directors.round_robin();
    vdir.add_backend(server1);
    vdir.add_backend(server2);
}

Varnishでは上記すべてのサーバがDOWNしている場合はGrace modeやKeepと合わせて、現在持ち合わせているキャッシュコンテンツでレスポンスを続けることが可能です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0