Lambda function time execution

0

I'm dealing with a lex bot that uses lambda function; this lex bot is integrated in the genesys cloud. when testing the lambda function I found that the execution time is about 8-9 s which is too long; I did not undrestand the root cause of this latency;

is there a way to know exactly using cloudwatch logs or lambda x-ray where exactly or the root cause of this latency ( exp: lack of memory, bad config, bad written script ... ) ?

1 Answer
2

There can be many factors attributing to this latency, such as runtime, memory allocation, cold start etc. I am assuming it's not running within VPC, if so, then VPC configuration can be another factor to this delay.

I'd suggest you to go through these two documentations and blog post:

Did you try to set provisioned concurrency to this lambda function, if not then give that a try and see if it reduces the delay. Very common cause of such delays can be cold start and with provisioned concurrency, this can be avoided up to an extent.

Edit: Please take a look at async-custom-metrics. Also, if you want to dig deeper into this, consider using X-Ray traces for this lambda function. In X-Ray traces, you can see how much time it took, timestamp when you ran the function and actual timestamp when your lambda code executed. Difference of this is the time of initialization, where it'd have resolved all the code dependencies, resource allocation etc.

Comment here if you have additional questions, happy to help.

Abhishek

profile pictureAWS
EXPERT
answered 13 days ago
profile pictureAWS
EXPERT
iBehr
reviewed 13 days ago
  • thank you for your response. what I suggest is so important and help a lot comprehension how to ameliorate the function runtime. But my truly issue, is how I can detect exactly the route cause of my latency, is there a tool, service... that can show me what is the root cause, example the time that the cold start took, the time to communicate with the dynamo...

  • Sorry for delayed response. Did you take a look at async-custom-metrics. Also, if you want to dig deeper into this, consider using X-Ray traces for this lambda function. In X-Ray traces, you can see how much time it took, timestamp when you ran the function and actual timestamp when your lambda code executed. Difference of this is the time of initialization, where it'd have resolved all the code dependencies, resource allocation etc. I'm adding this to my answer as well for better community experience. Please do let me know if you have anything further, I'd be happy to help.

  • catching Traces with aws X-ray , I found that the spending time is about 12.63 invocation time = 12.63 overhead time = 2ms

  • Did you try setting up provisioned concurrency and then compare the results.

  • yes, but nothing has changed

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions