Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why AWS lambda billing differ for different runtimes?

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?

like image 682
silent-box Avatar asked Jan 20 '26 04:01

silent-box


1 Answers

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.

like image 92
Shreyas Gaonkar Avatar answered Jan 21 '26 18:01

Shreyas Gaonkar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!