【发布时间】:2015-09-24 07:49:33
【问题描述】:
我在 NY2 地区的数字海洋中有 2 台清漆服务器。我在 Amazon EC2 us-east-1b 中有两台网络服务器。
Varnish 版本为 3.05,而 apache 在 Web 服务器上运行的版本为 2.4.6。我发现,在正常加载页面之前,加载的每个页面都会出现“504 Gateway Time-out”错误。有时,如果您再次点击该页面,它会再次出现超时错误。
这是一个令人讨厌的错误,我想尝试纠正。我尝试通过在清漆配置中将超时设置为非常高来解决这个问题。这停止了我遇到的 503 错误,但现在 504 错误是主要问题。
我有一个非常简单的清漆 VCL 文件。这里是:
backend web1 {
.host = "10.10.10.25";
.port = "80";
.connect_timeout = 1200s;
.first_byte_timeout = 1200s;
.between_bytes_timeout = 1200s;
.max_connections = 70;
.probe = {
.request =
"GET /healthcheck.php HTTP/1.1"
"Host: wiki.example.com"
"Connection: close";
.interval = 10m;
.timeout = 60s;
.window = 3;
.threshold = 2;
}
}
backend web2 {
.host = "10.10.10.26";
.port = "80";
.connect_timeout = 1200s;
.first_byte_timeout = 1200s;
.between_bytes_timeout = 1200s;
.max_connections = 70;
.probe = {
.request =
"GET /healthcheck.php HTTP/1.1"
"Host: wiki.example.com"
"Connection: close";
.interval = 10m;
.timeout = 60s;
.window = 3;
.threshold = 2;
}
}
director www round-robin {
{ .backend = web1; }
{ .backend = web2; }
}
sub vcl_recv {
if (req.url ~ "&action=submit($|/)") {
return (pass);
}
set req.backend = www;
return (lookup);
}
sub vcl_fetch {
set beresp.ttl = 3600s;
set beresp.grace = 4h;
return (deliver);
}
sub vcl_deliver {
if (obj.hits> 0) {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
}
当页面出现 504 错误时,这是我在清漆日志中遇到的错误:
10 TxHeader c Age: 1
10 TxHeader c Via: 1.1 varnish
10 TxHeader c Connection: close
10 TxHeader c X-Cache: MISS
10 Debug c Write error, retval = -1, len = 75311, errno = Connection reset by peer
10 ReqEnd c 1481957120 1436230882.856483936 1436230941.208484650 0.000118494 58.351872206 0.000128508
10 StatSess c 54.88.194.254 52474 58 1 1 0 0 1 565 74746
我检查了出现此错误后是否可以 curl 健康检查文件,并且似乎可以:
[root@varnish1:/etc/varnish] #curl http://wiki.example.com/healthcheck.php
good
这是一个奇怪的设置,但在我们获准在 EC2 中设置清漆之前还需要几周时间。这是我继承的设置,需要尝试使其在接下来的几周内可行。
如果您能提供任何帮助和见解,我将不胜感激。
【问题讨论】:
标签: varnish varnish-vcl