首页 > 解决方案 > Sam local with NodeJS - 请求在哪里花费这么多时间

问题描述

我已经编写了一个 NodeJS lambda 函数,我正在使用sam local. 我注意到浏览器下载它所花费的时间比我从日志中看到的 lambda 执行要多得多。Chrome 显示它在服务器响应之前等待了 6,13 秒。

2020-02-04 21:02:18 127.0.0.1 - - [04/Feb/2020 21:02:18] "GET /v1/verify/Yk6QwCF1 HTTP/1.1" 502 -
Invoking src/handlers/users/verifyUser.handler (nodejs10.x)
Fetching lambci/lambda:nodejs10.x Docker container image......
Mounting C:\dev\mezinamiridici\infrastructure as /var/task:ro,delegated inside runtime container
?[32mREPORT RequestId: 56060b6c-2bef-1241-03a4-fb2fca321096     Init Duration: 2238.80 ms       
Duration: 127.36 ms     Billed Duration: 200 ms Memory Size: 128 MB     Max Memory Used: 59 MB  ?[0m
2020-02-04 21:03:10 127.0.0.1 - - [04/Feb/2020 21:03:10] "GET /v1/verify/Yk6QwCF1 HTTP/1.1" 403 -

它应该是大约 2,5 秒。剩下的将近 4 秒用在了哪里?

Chrome 网络计时

源代码在那里:https ://github.com/literakl/mezinamiridici/blob/master/infrastructure/src/handlers/users/verifyUser.js

标签: node.jsaws-lambdaaws-sam

解决方案


推荐阅读