gpt4 book ai didi

amazon-web-services - ELB 保活超时 : Varnish Configuration Assistance

转载 作者:行者123 更新时间:2023-12-03 17:44:50 26 4
gpt4 key购买 nike

我希望配置 Varnish 以优化保持事件超时设置以与我的 ELB 一起使用。ELB 使用 Varnish 作为后端(为 Tomcat 提供缓存)。

Tomcat 内部设置了 120s 的 keep-alive timeout 值。测试它通过那个端口工作正常。

# time telnet XXX.XX.XX.XX 8080
Trying XXX.XX.XX.XX...
Connected to XXX.XX.XX.XX
Escape character is '^]'.
Connection closed by foreign host.

real 2m0.038s
user 0m0.002s
sys 0m0.004s

当我们尝试通过 Varnish 端口 9000 建立连接时,会在 6 秒内超时

[root@dev-server ~]# time telnet XXX.XX.XX.XX 9000
Trying XXX.XX.XX.XX...
Connected to XXX.XX.XX.XX.
Escape character is '^]'.
Connection closed by foreign host.

real 0m6.093s
user 0m0.001s
sys 0m0.005s

已经检查了 Varnish 的几个选项,但似乎没有任何效果。

我的后端 default.vcl 配置如下

backend Example {
.host = "localhost";
.port = "8080";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
.probe = {
.url = "/service/search/test";
.timeout = 500ms;
.interval = 5s;
.window = 10;
.threshold = 8;
}
}

一些论坛建议使用 idle_timeout 或 sess_timout,但这些都不是可接受的变量。我正在运行 Varnish 3.0.7,现在没有升级计划。

根据 AWS 支持,他们建议 ELB 空闲超时 + 1 秒用于保持事件超时,一般请求超时加倍。

例如;

ELB idle timeout = 60 s
Request timeout = 120 s
KeepAlive timeout = 61 s

我们正确设置了 ELB 超时,但只需要弄清楚我们如何在 Varnish 中设置它,因为连接会在 6 秒内关闭。理想情况下,我们希望它在 120 秒内关闭(与 Tomcat 中设置的值相同)

您的帮助将不胜感激。谢谢

最佳答案

几个论坛的建议都是对的,timeout_idle (以前在 Varnish 3 中称为 sess_timeout)是您正在寻找的设置:

  • Units: seconds
  • Default: 5

Idle timeout for persistent sessions. If a HTTP request has not been received in this many seconds, the session is closed.

但是,请注意,这是一个 varnishd 参数而不是 VCL 设置,因此它不会进入您的 VCL,而是作为命令行参数传递给 varnishd.

要应用,请将 -p sess_timeout=61 添加到传递给 varnishd 的命令行参数列表中。 (通常这个参数会被添加到您的发行版的 configuration file that starts varnish 中,例如,旧版 Debian/Ubuntu 上的 /etc/default/varnish)。

您需要记住重新启动 varnishd 进程(例如,sudo service varnish restart 在 Debian/Ubuntu 上)以使设置生效。

关于amazon-web-services - ELB 保活超时 : Varnish Configuration Assistance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39492154/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com