我有一个带有监听器规则的 ALB,该规则将传入请求(在路径和主机 header 上匹配)转发到目标组。该目标组以 Lambda 为目标来处理请求。
如果我向与该监听器规则匹配的 ALB 发送请求,则会触发某些内容,每隔几秒(大约每 35 秒)不断调用 lambda。
如果我用 API Gateway 替换 ALB 作为触发器,则 Lambda 仅被调用一次。
我不明白为什么 ALB 或目标组会以某种方式触发 Lambda 被多次调用。
最佳答案
您对 Lambda 目标组 (TG) 进行了运行状况检查,您可以modify or disable如果你喜欢。这些是对 Lambda 的定期“ping”,以断言和测试其状态。
根据 documentation ,如果目标类型是 Lambda,则 TG 的默认 HealthCheckIntervalSeconds
为 35 秒,这解释了时间安排:
HealthCheckIntervalSeconds
The approximate amount of time, in seconds, between health checks of an individual target. The range is 5–300 seconds. The default is 30 seconds if the target type is instance or ip and 35 seconds if the target type is lambda.
关于amazon-web-services - ALB 每 35 秒重复调用一次 AWS Lambda,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72065599/