Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any performance/functionality differences for AWS Lambda functions written in node.js/Java

I am planning to use AWS Lambda for the backend of an app. I am more comfortable with Java compared to node.js but I see Lambda functions in node.js are more popular than Java. Are there any performance differences between Java based and nodejs based lambda functions?

like image 706
suku Avatar asked May 02 '16 13:05

suku


People also ask

Which language is best for AWS Lambda?

The benefits of Python in AWS Lambda environments Python is without a doubt the absolute winner when it comes to spinning up containers. It's about 100 times faster than Java or C#.

Why node js is preferred for Lambda functions?

The reason Node. js is able to process many requests in parallel is because most of the time spent serving a request (within a typical Node. js application) takes place outside of JavaScript. Consider when an incoming HTTP request results in a call to a database.

Does AWS Lambda support node JS?

AWS Lambda now supports Node. js 16 as both a managed runtime and a container base image. Developers creating serverless applications in Lambda with Node. js 16 can take advantage of new features such as support for Apple silicon for local development, the timers promises API, and enhanced performance.


2 Answers

While Java has a slower startup time, it's runtime performance is a lot better than the one of node.js or Python. That means Java Lambda functions make sense if:

  1. They are Invoked regularly - AWS Lambda will reuse it's initialized containers and you can benefit from the better performance without the cold start latency

and/or

  1. They have a long runtime - If your function is running e.g. for 1 or 2 minutes, you do not really care about 5 seconds of startup if the function itself is running an order of magnitude faster than node.js

You may want to take a look at this github project that compares the cold start times.

One big factor of Java's bad cold starts is probably the fact that Java projects are often a lot bigger than e.g. a node.js function. In any way you should always try to keep functions as small as possible to reduce the initial latency.

And of course performance shouldn't be the only factor when choosing your programming language. I personally think node.js is extremely convenient when working e.g. with JSON data, this is why I use it in most of my functions.

like image 180
birnbaum Avatar answered Oct 21 '22 00:10

birnbaum


Java functions on Lambda generally require more resources and take much longer to respond from a cold start, when compared to NodeJS functions. Otherwise there is no difference.

like image 35
Mark B Avatar answered Oct 21 '22 01:10

Mark B