varnish-cache 作為負載平衡器的 vcl 設定有什麼問題?

varnish-cache 作為負載平衡器的 vcl 設定有什麼問題?

我在機器上的 default.vcl varnish 檔案上啟動了當前配置,以平衡其他兩台機器的負載(其他兩台機器也啟動了 varnish)。

我的目的是讓這台伺服器只進行負載平衡,其他機器進行處理以及它們自己的快取。

我的問題是,即使進行了配置測試(甚至沒有壓力測試或任何東西,每分鐘只有幾個請求),我也會收到大師冥想錯誤,並且必須重新啟動清漆。

這是負載平衡伺服器的default.vcl:

backend vader {
  .host = "app1.server.com";
  .probe = {
                .url = "/";
                .interval = 10s;
                .timeout = 4s;
                .window = 5;
                .threshold = 3;
  }
}

backend malgus {
  .host = "app2.server.com";
  .probe = {
                .url = "/";
                .interval = 10s;
                .timeout = 4s;
                .window = 5;
                .threshold = 3;
  }
}

director dooku round-robin {
        {
                .backend = vader;
        }
        {
                .backend = malgus;
        }
}

sub vcl_recv {
    if (req.http.host ~ "^balancer.server.com$") {
        set req.backend = dooku;
   }
}

我做錯了什麼或錯過了什麼嗎?


編輯:

這是 varnishlog 的輸出:

    0 CLI          - Rd ping
    0 CLI          - Wr 200 19 PONG 1345839995 1.0
    0 CLI          - Rd ping
    0 CLI          - Wr 200 19 PONG 1345839998 1.0
    0 CLI          - Rd ping
    0 CLI          - Wr 200 19 PONG 1345840001 1.0
    0 Backend_health - malgus Still sick 4--X--- 0 3 5 0.000000 3.846876 
    0 Backend_health - vader Still sick 4--X--- 0 3 5 0.000000 3.839194 
    0 CLI          - Rd ping
    0 CLI          - Wr 200 19 PONG 1345840004 1.0
   14 SessionOpen  c 10.150.7.151 38272 :80
   14 ReqStart     c 10.150.7.151 38272 458200540
   14 RxRequest    c GET
   14 RxURL        c /
   14 RxProtocol   c HTTP/1.1
   14 RxHeader     c Host: dooku-dev.excelsior.com
   14 RxHeader     c Connection: keep-alive
   14 RxHeader     c User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11
   14 RxHeader     c Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
   14 RxHeader     c Accept-Encoding: gzip,deflate,sdch
   14 RxHeader     c Accept-Language: en-US,en;q=0.8,es-419;q=0.6,es;q=0.4
   14 RxHeader     c Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
   14 RxHeader     c Cookie: SESSa87d6c6da0c61037a9169122dc5e4a19=HR_0Srhgc-uDArT3aJFzOBy31FtzneTXg38byr1eGMU; __atuvc=4%7C33
   14 VCL_call     c recv pass
   14 VCL_call     c hash
   14 Hash         c /
   14 Hash         c dooku-dev.excelsior.com
   14 VCL_return   c hash
   14 VCL_call     c pass pass
   14 FetchError   c no backend connection
   14 VCL_call     c error deliver
   14 VCL_call     c deliver deliver
   14 TxProtocol   c HTTP/1.1
   14 TxStatus     c 503
   14 TxResponse   c Service Unavailable
   14 TxHeader     c Server: Varnish
   14 TxHeader     c Content-Type: text/html; charset=utf-8
   14 TxHeader     c Retry-After: 5
   14 TxHeader     c Content-Length: 418
   14 TxHeader     c Accept-Ranges: bytes
   14 TxHeader     c Date: Fri, 24 Aug 2012 20:26:44 GMT
   14 TxHeader     c X-Varnish: 458200540
   14 TxHeader     c Age: 0
   14 TxHeader     c Via: 1.1 varnish
   14 TxHeader     c Connection: close
   14 Length       c 418
   14 ReqEnd       c 458200540 1345840004.916415691 1345840004.965190172 0.020933390 0.048741817 0.000032663
   14 SessionClose c error
   14 StatSess     c 10.150.7.151 38272 0 1 1 0 1 0 256 418
   14 SessionOpen  c 10.150.7.151 38273 :80
   14 ReqStart     c 10.150.7.151 38273 458200541
   14 RxRequest    c GET
   14 RxURL        c /favicon.ico
   14 RxProtocol   c HTTP/1.1
   14 RxHeader     c Host: dooku-dev.excelsior.com
   14 RxHeader     c Connection: keep-alive
   14 RxHeader     c Accept: */*
   14 RxHeader     c User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11
   14 RxHeader     c Accept-Encoding: gzip,deflate,sdch
   14 RxHeader     c Accept-Language: en-US,en;q=0.8,es-419;q=0.6,es;q=0.4
   14 RxHeader     c Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
   14 RxHeader     c Cookie: SESSa87d6c6da0c61037a9169122dc5e4a19=HR_0Srhgc-uDArT3aJFzOBy31FtzneTXg38byr1eGMU; __atuvc=4%7C33
   14 VCL_call     c recv pass
   14 VCL_call     c hash
   14 Hash         c /favicon.ico
   14 Hash         c dooku-dev.excelsior.com
   14 VCL_return   c hash
   14 VCL_call     c pass pass
   14 FetchError   c no backend connection
   14 VCL_call     c error deliver
   14 VCL_call     c deliver deliver
   14 TxProtocol   c HTTP/1.1
   14 TxStatus     c 503
   14 TxResponse   c Service Unavailable
   14 TxHeader     c Server: Varnish
   14 TxHeader     c Content-Type: text/html; charset=utf-8
   14 TxHeader     c Retry-After: 5
   14 TxHeader     c Content-Length: 418
   14 TxHeader     c Accept-Ranges: bytes
   14 TxHeader     c Date: Fri, 24 Aug 2012 20:26:45 GMT
   14 TxHeader     c X-Varnish: 458200541
   14 TxHeader     c Age: 0
   14 TxHeader     c Via: 1.1 varnish
   14 TxHeader     c Connection: close
   14 Length       c 418
   14 ReqEnd       c 458200541 1345840005.226389885 1345840005.226457834 0.000026941 0.000043154 0.000024796
   14 SessionClose c error
   14 StatSess     c 10.150.7.151 38273 0 1 1 0 1 0 256 418

答案1

您的伺服器有連線問題。我發現您在後端使用 DNS 位址。 Varnish 在啟動時解析 DNS,不會注意到執行時間的變化。

自 Varnish 啟動以來,您是否更改了 FQDN 目標?

您的 DNS 是否以動態位址為目標?

您應該嘗試使用靜態 IP 而不是 DNS 名稱。

答案2

事實證明,後端伺服器花費了大量時間來處理請求。我將架構從 un varnish 負載平衡器變更為每台伺服器和一個負載平衡器。

相關內容