簡體   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