You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS ECS自动扩容时ALB出现临时504超时问题求助

ECS+EC2架构自动扩容时ALB出现短暂504网关超时问题

我们的服务采用ECS+EC2架构,已配置ECS服务自动扩容。当自动扩容策略触发新增任务时,ALB偶尔会出现短暂的504网关超时现象。

已排查内容

  • 该现象仅在新实例刚注册到ALB时发生,持续1-2分钟;
  • 有时ALB显示实例健康、ECS显示任务运行且健康,有时实例短暂不健康后恢复。按AWS文档,ALB仅向健康实例转发流量;
  • 仅极少量请求(<1%)超时;
  • 目标响应时长未接近或超出180秒的空闲超时,且无TargetConnectionErrorCount指标异常。

ALB访问日志示例

日志中request_processing_time为-1,疑似ALB与目标连接存在问题:

type: https
time: 2024-07-25T22:12:31.373696Z
elb: app/xxxx/b3e537e604573ca5
client:port: 52.26.185.88:13328
target:port: 10.0.228.223:8443
request_processing_time: -1
target_processing_time: -1
response_processing_time: -1
elb_status_code: 504
target_status_code: -
received_bytes: 2324
sent_bytes: 292
request: "POST https://xxxxx:443/ HTTP/1.1"
user_agent: "xxxxx"
ssl_cipher: ECDHE-RSA-AES128-GCM-SHA256
ssl_protocol: TLSv1.2
target_group_arn: xxxxxxxx
trace_id: "Root=1-xxxxx-xxxxxxx"
domain_name: "xxxxxx"
chosen_cert_arn: "session-reused"
matched_rule_priority: 0
request_creation_time: 2024-07-25T22:12:21.374000Z
actions_executed: "waf,forward"
redirect_url: "-"
error_reason: "-"
target:port_list: "10.0.228.223:8443"
target_status_code_list: "-"
classification: "-"
classification_reason: "-"
conn_trace_id: xxxxxx

指标关联图

504指标与runningTaskCount指标关联图

我猜测新注册主机可能未真正健康,但ALB仍转发了流量,却不知如何验证。恳请告知可能的原因及解决办法。


内容的提问来源于stack exchange,提问作者Erin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 11:42:40