aws / aws-lambda-base-images

Apache License 2.0
648 stars 107 forks source link

Node v18 Released #47

Closed chenrui333 closed 1 year ago

chenrui333 commented 2 years ago

Even though we are still waiting for node v16 base image, this is the issue tracker for node v18 base image

https://nodejs.org/en/blog/announcements/v18-release-announce/

thdxr commented 1 year ago

what linux kernel version is this using?

GrahamCampbell commented 1 year ago

the same as the node 16 ones i presume. the one al2 uses.

jtuliani commented 1 year ago

The kernel is not part of the runtime. All Lambda runtimes inherit their kernel from the MicroVM in which they run (see diagram on page 11 of https://docs.aws.amazon.com/pdfs/whitepapers/latest/security-overview-aws-lambda/security-overview-aws-lambda.pdf). Currently, this is kernel v4.14.

michael-k commented 1 year ago

Release 1.65.0 of AWS SAM CLI comes with support for Node.js 18.x.

antspk commented 1 year ago

2.51.0 AWS CDK comes with Node.js 18 runtime support as well 🎉 . Keen to see when it's going to be available on codebuild as well.

michael-k commented 1 year ago

For CodeBuild see aws/aws-codebuild-docker-images#580

RaphaelManke commented 1 year ago

I've build a cdk example that uses the node 18 runtime. https://github.com/RaphaelManke/cdk-lambda-node-18

o-alexandrov commented 1 year ago

Please let us know when to expect:

Sparticuz commented 1 year ago

https://docs.aws.amazon.com/lambda/latest/dg/lambda-nodejs.html?icmpid=docs_lambda_rss

Looks like it's hit lambda proper.

jtuliani commented 1 year ago

Node 18 support in Lambda has shipped!

https://aws.amazon.com/about-aws/whats-new/2022/11/aws-lambda-support-node-js-18/

https://aws.amazon.com/blogs/compute/node-js-18-x-runtime-now-available-in-aws-lambda/

Thank you all for the input and feedback on this thread.

laymonage commented 1 year ago

Node.js 16 release: 2021-04-20 Node.js 16 active LTS start: 2021-10-26 AWS Lambda Node 16 support: 2022-05-12 LTS-to-support: 198 days

Node.js 18 release: 2022-04-19 Node.js 18 active LTS start: 2022-10-25 AWS Lambda Node 18 support: 2022-11-18 LTS-to-support: 24 days

That's a big improvement!

I remember a lot of people (myself included) complaining about how Node.js 16 support came very late. Now that Node.js 18 support came in a reasonably timely manner, I feel we need to give credit where it's due 🙂

Congratulations and thanks @jtuliani & team! 🎉

Now, see if AWS can beat the record when Node.js 20 comes out 😜

jlarmstrongiv commented 1 year ago

Great news!

@jtuliani will you and the team update https://github.com/aws/aws-lambda-nodejs-runtime-interface-client to match the Node.js 18 release?

Features described in the blog post, like ES Module support https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/issues/44, do not work. This support is very important for custom docker containers.

paul-uz commented 1 year ago

Excellent news, and the cherry on the top is that the ESM Module & Lamda Layer issue has also been fixed 🙏

jtuliani commented 1 year ago

@jlarmstrongiv You're right that the public runtime interface client is not currently in sync with our Node 18 version. It is something we want to address. Can I suggest you file a separate issue for this, for tracking purposes and for others to weigh in with their feedback?

jtuliani commented 1 year ago

Thank you @paul-uz and @laymonage for your kind words. We're still not where we'd like to be across other languages, but we are continuing our work to improve.

chenrui333 commented 1 year ago

@jtuliani Congratulations on the nodejs v18 runtime release!

Worth calling out that the node.js 18 runtime seems slower than the node.js 16 runtime, any reason why that happened? Thanks! https://twitter.com/sussmansa/status/1593804631192346624?s=46&t=faTnOE-p9Hnj0qf7-KYT2g

daniele-sarnari-blinkoo commented 1 year ago

Do you know how to create lambda using node.js 16? I can't create a lambda edge because nodejs 16 is no more available

paul-uz commented 1 year ago

Do you know how to create lambda using node.js 16? I can't create a lambda edge because nodejs 16 is no more available

Why can't you use 18?

daniele-sarnari-blinkoo commented 1 year ago

Do you know how to create lambda using node.js 16? I can't create a lambda edge because nodejs 16 is no more available

Why can't you use 18?

image
daniele-sarnari-blinkoo commented 1 year ago

nvm, fixed with aws lambda update-function-configuration --function-name <funcname> --runtime nodejs16.x

willfarrell commented 1 year ago

Big congrats to the lambda runtime team on this release! Exciting to see the ESM + Lambda layer now supported.

Middy v4 is now released for nodejs18.x runtime and now uses AWS SDK v3.

JacksonGariety commented 1 year ago

I'm curious about the cold start problem pointed out by @chenrui333. Can the AWS team shed some light on this?

jtuliani commented 1 year ago

@chenrui333 @JacksonGariety We're aware of the reports of longer cold starts on Node 18 and we're investigating the issue. We'll report back once those investigations are complete.

paul-uz commented 1 year ago

@jtuliani I found this issue, https://github.com/aws/aws-sdk-js-v3/issues/4225, when writing some new functions.

Is this intended behaviour?

I (probably wrongly) assumed that the embedded SDK would work in combination with a local node_modules folder in the function, but it seems like it doesn't.

jtuliani commented 1 year ago

@paul-uz Thanks for flagging, I'll find out and revert.

dvargas92495 commented 1 year ago

@jtuliani Any ETA on when node18 will be supported in Lambda@Edge?

Screen Shot 2022-11-28 at 12 13 14 AM

aukevanleeuwen commented 1 year ago

@chenrui333 @JacksonGariety We're aware of the reports of longer cold starts on Node 18 and we're investigating the issue. We'll report back once those investigations are complete.

@jtuliani we are also experiencing this. Is there a GitHub issue or somewhere else where we can track the progress on this investigation? This is blocking us from moving away from 16 at the moment.

o-alexandrov commented 1 year ago

cc @jtuliani Regarding cold starts, there's a great article by Yan Cui from a couple of years ago that is still applicable. TLDR img from the article is attached below.

For best performance/cold starts, bundle aws-sdk and don't depend on AWS-provided SDK

Unfortunately, AWS didn't (or couldn't) listen to the community in the Node.js v16 thread, so we don't have an SDK-free node.js (hopefully soon Bun also) runtime.

coldstarts

asilvas commented 1 year ago

Bun support would be a perfect fit for lambda's due to fast cold start, but it's quite a few months from v1 and I doubt AWS will even consider it prior to that.

paul-uz commented 1 year ago

Bun support would be a perfect fit for lambda's due to fast cold start, but it's quite a few months from v1 and I doubt AWS will even consider it prior to that.

I doubt we'll ever see the likes of Bun or even Deno. Shame.

o-alexandrov commented 1 year ago

@jtuliani thank you for the new feature, AWS Lambda runtime management controls.

jtuliani commented 1 year ago

@o-alexandrov Supporting new runtimes such as Deno or Bun would be a separate feature, it's not enabled by runtime management controls. I'm interested to learn more about your use case for Deno and/or Bun. How would they help you?

o-alexandrov commented 1 year ago

@jtuliani thank you for considering this request. imho:

santiperone commented 1 year ago

@jtuliani Has there been any updates on the cold start issue with node.js v18?

paul-uz commented 1 year ago

@jtuliani Has there been any updates on the cold start issue with node.js v18?

What's the cold start issue?

santiperone commented 1 year ago

@jtuliani Has there been any updates on the cold start issue with node.js v18?

What's the cold start issue?

Node 18 has longer cold start in comparison to node 16

@chenrui333 @JacksonGariety We're aware of the reports of longer cold starts on Node 18 and we're investigating the issue. We'll report back once those investigations are complete.

jtuliani commented 1 year ago

@santiperone Thanks for following up. We have identified the primary cause of the longer cold starts in the Node 18 runtime as thread blocking in a dependency used during initialization. We are evaluating options to resolve this in a future Node 18 runtime update.

paul-uz commented 1 year ago

@santiperone Thanks for following up. We have identified the primary cause of the longer cold starts in the Node 18 runtime as thread blocking in a dependency used during initialization. We are evaluating options to resolve this in a future Node 18 runtime update.

What's the rough ETA on that update? I hope its sometime this year...

thdxr commented 1 year ago

that's excellent news, is it something in the aws lambda runtime interface client?

willfarrell commented 1 year ago

This was in a newsletter from Node Weekly I received today:

Lambda Cold Starts is a neat page giving a live demonstration of how quickly different AWS Lambda serverless runtimes take to start. Given Node's mature status on Lambda, it does surprisingly poorly?

Seems others have noticed too.

paul-uz commented 1 year ago

This was in a newsletter from Node Weekly I received today:

Lambda Cold Starts is a neat page giving a live demonstration of how quickly different AWS Lambda serverless runtimes take to start. Given Node's mature status on Lambda, it does surprisingly poorly?

Seems others have noticed too.

How embarrassing.

o-alexandrov commented 1 year ago

This is slightly related to performance questions:

Maybe, AWS would kindly consider to provide us with managed by AWS Bun runtime.

bicatu commented 1 year ago

any news regarding this issue? is there a ticket we can subscribe to be notified of this progress?

o-alexandrov commented 1 year ago

@chenrui333 @JacksonGariety We're aware of the reports of longer cold starts on Node 18 and we're investigating the issue. We'll report back once those investigations are complete.

@bicatu this ticket is closed, Node.js 18 is available for all Lambda, including Lambda@Edge (support added in January 2023 if I'm not mistaken), some of us just shamelessly pinged AWS here 😅 having an opportunity to be heard

I just created a separate ticket #83 regarding cold starts, so it's in Open state and has less probability of being postponed.

ffxsam commented 1 year ago

There's still the issue of performance when using the built-in runtime's SDK: https://dev.to/aws-builders/benchmarking-the-aws-sdk-2pd4

paul-uz commented 1 year ago

@ffxsam funnily enough, I read that same article last night.

Anyone here got a good example/tutorial on using esbuild with Typescript and tree shaking? I can't seem to find anything decent online :/

ffxsam commented 1 year ago

@paul-uz What, specifically, are you looking for?

paul-uz commented 1 year ago

@ffxsam how to configure esbuild to compile TS and do tree-shaking (and minification).

ffxsam commented 1 year ago

@paul-uz Tree-shaking is automatic in esbuild, as far as I know. As a test, just create an index.ts file and add a package (like date-fns). Import a function from date-fns, use it in some way, then do:

$ esbuild index.ts --bundle --format=cjs --minify --outfile=min.js

Or --format=esm depending on where you're deploying.

paul-uz commented 1 year ago

@ffxsam oh sweet. TBH I've simply not yet tried it, as we currently just use TS to compile the JS files, and bundle all the production NPM dependencies in a ZIP.

So, I can use esbuild to compile the TS into JS, at the same time, tree-shaking and minifying everything? So in theory I would end up with a JS file and a trimmed down node_modules folder? Or does esbuild create something else that gets imported?