It seems like just yesterday we ran Lambda functions on Node.js version 6.10 or 8.10, but this year, AWS released official support for Node.js 10 and set Node.js 8.10, which will reach its EOL at the end of 2019.

This time AWS released the support for Node.js 12! Node.js 12 (AKA “Erbium”) which is the official LTS version.

The current state of supported runtimes is:

Name Identifier Node.js Version AWS SDK for JavaScript Operating System
Node.js 12 nodejs12.x 12.13.0 2.536.0 Amazon Linux 2
Node.js 10 nodejs10.x 10.16.3 2.448.0 Amazon Linux 2
node.js runtimes

List of recent runtimes

Node.js 12 vs Node.js 10

The most notable differences between the versions are:

  1. V8 updated to version 7.4:
    • Async stack traces arrived
    • Faster async/await implementation
    • New JavaScript language features
    • Performance tweaks & improvements
    • Progress on Worker threads, N-API
  2. import/export statements supported (no bundler required)
  3. Default HTTP parser switched to llhttp
  4. New experimental “Diagnostic Reports” feature
  5. Private Class Fields

You can read more about the changes here and here.

Performance comparison

At Epsagon, we already support the latest version in the tracing library, and as always – we love to benchmark and compare between different runtimes. We conducted the test on a 128MB Lambda, with the following simple snippet of a Fibonacci’s sequence:

function fib(n) {
    if (n < 2){
        return n
    }
    return fib(n - 1) + fib(n - 2)
}

exports.handler = async (event) => {
    for (var i =0 ; i<1000 ; i++) {
        fib(20)
    }
    const response = {
        statusCode: 200,
        body: fib(20),
    };
    return response;
};

We measured both the cold starts and the avg. duration of the function, using artillery, over a period of an hour. The results were a bit surprising:

node.js

It seems that v12 is performing a bit slower in both the average cold start duration and the general average duration for the response. This, however, might happen due to the fact it’s still new, and let’s not forget that we got a bunch of new features.

AWS Lambda, Node.js and much more in our blog:

AWS Lambda and Secret Management

Building a Serverless App Using Athena and AWS Lambda

How to Free AWS Lambda Code Storage 

AWS Lambda and Express – Getting Started Guide