跳至内容

HELP: My hello-world Nodejs Lambda function is slow! (150ms avg.)

0

Video showcasing it: https://gyazo.com/f324ce7600f7fb9057e7bb9eae2ff4b1 My lambda function:

export const main = async (event, context) => {  
  return {
    statusCode: 200,
    body: "Hello World!",
    headers: {
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Credentials": true,
    },
  };
}
  • ✅I have chosen my closest region (frankfurt) (with avg. ping of 30ms)
  • ✅I have tried doubling the default memory amount for it
  • ✅I have tried screaming at the computer

runtime: "nodejs18.x", architecture: "arm_64",

The function actually only takes ~10-20ms to execute, so what accounts for the remaining 140ms of wait time? https://i.gyazo.com/2da0e649ea7ea5f9a137053cb404b400.png

已提问 1 年前243 查看次数
2 回答
0

Looking at the video I see additional printouts, which indicate that you have some dependencies that you load and they probably take some time to initialize.

AWS
专家
已回答 1 年前
0

Perhaps turn on X-Ray as a method of troubleshooting.

https://docs.aws.amazon.com/xray/latest/devguide/xray-services-lambda.html

AWS
专家
已回答 1 年前
专家
已审核 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。