Node.js runtime for serverless applications on AWS Lambda
We use Node.js extensively to create serverless applications and websites running on Lambda functions within Amazon Web Services (AWS).
Lambda is AWS's serverless compute offering, providing pay-per-invocation server power for short-lived server operations. Think of Lambda as a single function, performing a single operation and then returning a response or handing off to other cloud services. You only use the server for a short period, often milliseconds, and you only pay for the time the Lambda runs, with a multiplier for the memory and compute power provisioned. This technology is perfect for applications we've developed such as scalabe API's which can operate at zero-cost when idle but scale to many millions of invocations per day.
What's Node.js and why is version 10 being made end-of-life?
Node.js is an open-source JavaScript runtime environment that runs JavaScript code outside of a browser, as a server-side programming language. It's one of the many native runtimes that AWS Lambda can support, although Lambda can also support many more runtimes via Layers, such as PHP with Bref.
One of the fantastic things about AWS Lambda is that you just choose the runtime and major version and deploy your code - then AWS take care of the minor and patch versions and all necessary updates. There's no servers to maintain or monitor.
As with any open-source software Node.js has a release cycle, with versions being released and older versions deprecated periodically, to keep the library current and secure. Version 10.x of Node.js is end-of-life on April 30, 2021 - receiving no further updates or security patches - and so AWS are removing support for version 10 of Node.js in AWS Lambda.
What is AWS's Node.js 10 deprecation process?
AWS are deprecating Node.js 10.x for AWS Lambda in two stages:
- Starting July 30, 2021, Lambda will no longer apply security patches and other updates to the Node.js 10 runtime used by Lambda functions, and functions using Node.js 10 will no longer be eligible for technical support. In addition, you will no longer be able to create new Lambda functions using the Node.js 10 runtime
- Starting Aug 30, 2021, you will no longer be able to update existing functions using the Node.js 10 runtime
Updating AWS Lambda functions to upgrade from Node.js 10.x
AWS advise to update Lambda functions from Node.js 10 to Node.js 14.x, which is the current Long-Term Support (LTS) version and is the highest version of Node.js currently supported by AWS Lambda.
However one caveat is that Lambda@Edge does not support Node.js version 14, so Lambda@Edge functions should be updated to Node.js 12.
When moving from one major version to another there are a number of things to consider. Before updating our production Lambdas we'll be following a careful testing and deployment process such as:
- Provisioning our existing Lambda function code onto new runtimes either locally or in a safe development environment
- Running them against the lastest version of Node.js 14.x
- Updating dependencies with Node Package Manager (npm) to ensure compatibility
- Re-writing Lambda code and/or replacing incompatible dependencies
- Writing and running tests and confirming expected behaviour between old and new versions of the functions and between the old Node.js 10 runtime and the latest Node.14.x runtime
- Updating our Cloudformation, serverless framework or custom deploy scripts to ensure the new 14.x runtime is specified for Lambda
- Deploying the changes into our production environments and monitoring to ensure continued smooth operation
We've already begun this process for our own Lambda functions, and we'll working with our clients over the summer of 2021 to ensure all the Lambda Node.js updates are made smoothly and succesfully.