作为负载均衡器的 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 负载均衡器更改为每台服务器各一个负载均衡器。

相关内容