Search code examples
amazon-web-servicesaws-lambdaaws-api-gateway

Measure AWS Lambda startup duration


I am currently collecting and logging performance metrics of my function and the only metric I am missing is the startup duration (my function is pretty large, about 35MB compressed). I really need to know how long the startup takes and, even more important, how often it occurs (I have the feeling it is occurring way more often since my concurrent executions limit has been raised).

Is there any way to retrieve this information in Lambda? Or can someone think of a possibility to pass the current timestamp of an API Gateway call via e.g. the mapping template, so I can compute the startup time by myself?


Solution

  • AWS has recently introduced a Init Duration in cloudwatch logs alongside Billed Duration log for measuring a cold start lambda's before the actual invocation begins.

    From the "Report" section inside Lambda Log Stream

    Here's a sample log from one of my lambda -

    Duration: 1200.50 ms 
    Billed Duration: 1300 ms 
    Memory Size: 3008 MB 
    Max Memory Used: 308 MB 
    Init Duration: 4317.73 ms