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

yasdfjb
asked 12 days ago128 views
2 Answers
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.

profile pictureAWS
EXPERT
Uri
answered 12 days ago
0

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

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

profile pictureAWS
EXPERT
iBehr
answered 12 days ago
profile picture
EXPERT
reviewed 12 days ago