'Difference between aws lambda duration and my measures duration
I have aws lambda running python 3 service. I am measuring my service duration(simple time -time) from the start of the lambda invocation(first invocation line) till the end(last invocation line). Im getting results that are pretty dramatically different than aws reported duration and billed duration. Most of the time my measures indicates on average of 730.9 ms And aws reported duration and billed duration reports on Duration: 1058.36 ms Billed Duration: 1100 ms. Where the difference can come from?
Solution 1:[1]
Prior to function invocation, the instance must be spun up. I believe AWS Lambda charges for the setup time of the function as part of the execution time.
Any imports or other assets that must be loaded before your function is invoked count against the total execution time, and your timer doesn't start until after that inital loading time.
Solution 2:[2]
Difference between Duration and Billed Duration could be described by the 100ms duration billing granularity used that time by Lambda.
Now (since December 2020) the granularity is 1ms.
Interesting if author managed to fair the difference between his measurements and Lambda's measurements.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sam Morgan |
Solution 2 | Roman Kovtuh |