3

I am testing applications with two different runtimes: node.js and java native executable (ahead of time compiled with GraalVM).

Here are the startup logs.

Node.js:

Duration: 556.31 ms Billed Duration: 600 ms Memory Size: 128 MB Max Memory Used: 81 MB Init Duration: 365.44 ms

Native executable:

Duration: 548.98 ms Billed Duration: 1000 ms Memory Size: 256 MB Max Memory Used: 106 MB Init Duration: 411.83 ms

As you can see, Duration and Init duration are very close, but for some reason Billed Duration is almost 2 times more for the custom runtime with native executable.

Could you please explain what is the difference and how I can avoid that?

silent-box
  • 1,649
  • 3
  • 21
  • 40
  • Try to set the memory the same. Lambda's are billed in "gb-seconds". So it's more expensive to run with more memory. Using the calculater [here](https://aws.amazon.com/lambda/pricing/) with 10000000 requests, 600ms execution time, a 128 MB Lambda costs USD $7.63. A 256MB Lambda costs USD $20.13 - nearly 3X the cost. In general, if you have very short running Lambda's like this interpreted languages like Node will be cheaper. If you have longer running Lambda's, compiled languages will be cheaper. That a very general statement though. – stdunbar Apr 15 '20 at 02:28
  • Thanks, I tried. Same results, it just works a bit slower. 700 ms duration, 1200 billed duration – silent-box Apr 15 '20 at 02:58

1 Answers1

3

For custom runtimes, you are billed for the init time as well as mentioned in the docs -

"Initialization counts towards billed execution time and timeout. When an execution triggers the initialization of a new instance of your function, you can see the initialization time in the logs and AWS X-Ray trace."

548.98 ms (function duration) + 411.83 ms (init) = ‭960.81‬ms rounded off to next 100ms resulting in Billed Duration: 1000 ms

For the runtimes which Lambda supports; init time isn't counted towards the billed duration.

Shreyas Gaonkar
  • 265
  • 2
  • 5