繁体   English   中英

AWS Gateway永远需要调用lambda函数

[英]AWS Gateway takes forever to call the lambda function

我设置了一些日志以检查端点的传入请求。 我发现Gateway至少需要10秒钟才能调用lambda函数:

2016-03-05 21:32:19 UTC+1 Starting execution for request: 5b673e5b-e311-11e5-bf9b-33cf30c5916a
2016-03-05 21:32:19 UTC+1 Method request path: {}
2016-03-05 21:32:19 UTC+1 Method request query string: {}
2016-03-05 21:32:19 UTC+1 Method request headers:
2016-03-05 21:32:19 UTC+1 Method request body before transformations:
2016-03-05 21:32:19 UTC+1 Endpoint request URI:
2016-03-05 21:32:19 UTC+1 Endpoint request headers:
2016-03-05 21:32:19 UTC+1 Endpoint request body after transformations:
### THE CALL IS HERE ###
2016-03-05 21:32:30 UTC+1 Endpoint response body before transformations:
2016-03-05 21:32:30 UTC+1 Endpoint response headers:
2016-03-05 21:32:30 UTC+1 Method response body after transformations:
2016-03-05 21:32:30 UTC+1 Method response headers:
2016-03-05 21:32:30 UTC+1 Successfully completed execution
2016-03-05 21:32:30 UTC+1 Method completed with status: 200

以及来自lambda函数的日志:

2016-03-05 21:32:29 UTC+1 START RequestId: 5b678c7a-e311-11e5-a92e-7109901c2d08 Version: 65 
2016-03-05 21:32:30 UTC+1 END RequestId: 5b678c7a-e311-11e5-a92e-7109901c2d08 
2016-03-05 21:32:30 UTC+1 REPORT RequestId: 5b678c7a-e311-11e5-a92e-7109901c2d08  Duration: 699.25 ms Billed Duration: 700 ms Memory Size: 128 MB Max Memory Used: 41 MB

那是正常的吗? 我怎样才能加快速度?

谢谢。

这不是典型的情况,但是由于Lambda函数初始化(即“冷启动”行为),您可能会看到一小部分请求花费的时间比平均时间长得多。 您无需为初始化时间付费,因此您不会在Lambda日志中看到总时间。

避免这些高延迟情况的最佳建议:

  • 确保您的Lambda函数分配了足够的内存
  • 确保您的Lambda函数接收一致的流量,以使该函数保持“温暖”状态

如果您遵循此建议,但仍然在许多请求中看到此范围内的一致延迟,请告诉我们。

干杯,瑞安

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM