skip to Main Content

I have a lambda that keep experiencing cold start.
I configured the lambda to have 5 provisioned concurrency, as it was suggested as a possible solution, but the lambda still have cold starts.

What might be a possible explanation?
Maybe 5 provisioned concureency is not enough? (how can I know what will be a good amount of containers?)

How did you handle cold start?

Also, a very important question: how can I be sure it uses my lambdas? where can I monitor it?

thanks!

2

Answers


  1. Some possible directions to avoid cold starts:

    1. try to keep the lambdas warm – by scheduling a ping call to a dummy method every 1 minute or so
    2. check your code – cold start happens due to a lot of code/libraries being loaded into memory when the function starts. Try loading only the minimal possible when the function is invoked, and load any additional libraries dynamically only when they are required. (You can do that by using require('your-lib-name-here') in node.js or via reflection in C#)
    Login or Signup to reply.
    1. You can definitely try the steps given by LiriB to optimize the cold start.

    2. Also, you can monitor the the metrics for Invocations which will give you the clue of total Invocations:
      Here is one of the sample code for metric:{ "metrics": [ [ "AWS/Lambda", "Invocations", "FunctionName", "dataservice-funct-getclaimfreqpred", "Resource", "function_name:alias", { "color": "#2ca02c" } ], [ ".", "ConcurrentExecutions", ".", ".", ".", ".", { "color": "#9467bd" } ], [ ".", "Errors", ".", ".", ".", ".", { "stat": "Average", "color": "#ff7f0e" } ], [ ".", "Duration", ".", ".", ".", ".", { "stat": "Average", "color": "#1f77b4" } ] ], "view": "timeSeries", "stacked": false, "region": "region_name", "stat": "Sum", "period": 300, "title": "title" }

    3. Additionally you can follow the auto-scaling-provisioning for auto-scaling

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search