我已将 haproxy 设置为两个 varnish 服务器(即 srvA、srvB)的前端。srvA 和 srvB 上也运行有 nginx,varnish 用作这些服务器的前端。几天前,我们收集了统计数据,以查明有多少由 varnish 缓存(即具有两个 X-Varnish 值)处理的请求在 haproxy 上超时。有趣的是,我们发现来自 varnish 的响应中几乎有 30% 超时。
以下是 json 日志的片段:
{"http":{"domain":"blah_blah_blah","request_method":"GET","request_protocol_version":"1.1","browser":"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.3 (KHTML
, like Gecko) Chrome/6.0.472.63 Safari/534.3","request_url":"/images/loading.gif","referrer":"http://blah_blah_blah","request_cookie":null,
"return_code":200,"response_cookie":null,"byte_size":9754,"request_protocol":"HTTP"},"visitor":{"visit_unix":1286859600,"visit_unix_block_hour":1286859600,"geo":{"city":"blah"
,"region":"blah","organization":"blah","country_code":"blah","country_name":"blah","country_code3":"blah"},"visit_date":"2010-10-12 00:00:00","visitor_i
p":"111.111.111.111","visit_date_block_hour":"2010-10-12 00:00:00","visitor_port":49800},**"haproxy":{"listener_queue":0,"total_time_waiting_in_queue_ms":0,"feconn":1687,"haproxy_da
emon_pid":5318,"total_time_to_establish_tcp_conn_ms":0,"beconn":1657,"listener_name":"slideshare","request_processing_time_ms":0,"srv_conn":32,"server_name":"blah_backend",
"total_session_duration_time_ms":5013,"retries":0,"frontend":"srvA","termination_state":"cD--","haproxy_ip":"10.17.111.8","srv_queue":0,"total_time_to_receive_client_request_ms":
13,"actconn":1766,"haproxy_daemon":"haproxy"}**,"caching":{"x_varnish_cache_cur":2021094722,"x_varnish_cache_orig":2015028484,"x_varnish_cached":true},"app":{"x_bench_route_control
ler":null,"x_bench_route_action":null,"x_bench_db_count":null,"x_bench_db_time":null,"x_bench_route":null}}
如上面的代码片段所示,Varnish 返回了两个X-Varnish
标头值(2021094722 和 2015028484)。但是,这导致连接处于终止状态haproxy
。
我对此真的很困惑。请帮我理解为什么会发生这种情况。
答案1
我没有看到那篇文章。仅供参考,“cD”标志表示客户端超时,因此它与 varnish 无关,而是与客户端(另一侧)有关。如果太多客户端遇到超时,则可能是您的 haproxy 配置错误(可能是客户端超时太小)。