2016-03-05 65 views
0

我设置了一些日志来检查端点的传入请求。 我发现网关至少需要10秒来调用lambda函数:AWS网关需要永久调用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 

是正常吗?我如何加快速度?

谢谢。

+0

这是可重复的吗?总是或间歇地? –

+0

听起来像是用AWS支持开票的东西 – Max

+0

是的,它是可重复的,并不总是10秒。有时候4. – Erem

回答

2

这不是典型的,但是由于Lambda函数初始化,即“冷启动”行为,您可能会看到一小部分请求比平均时间长得多。您没有为初始化时间收费,所以您没有看到Lambda日志中的总时间。

最好的建议,以避免这些高最坏情况下的延迟:

  • 确保您的lambda表达式有足够的内存分配
  • 确保您的拉姆达函数接收顺序一致流量,以保持功能“暖”

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

干杯, 瑞安