silent-box
silent-box

Reputation: 1666

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?

Upvotes: 3

Views: 938

Answers (1)

Shreyas Gaonkar
Shreyas Gaonkar

Reputation: 283

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.

Upvotes: 3

Related Questions