在node.js / Java中编写的AWS Lambda函数是否存在任何性能/功能差异 [英] Are there any performance/functionality differences for AWS Lambda functions written in node.js/Java

查看:134
本文介绍了在node.js / Java中编写的AWS Lambda函数是否存在任何性能/功能差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划将AWS Lambda用于应用程序的后端。与node.js相比,我对Java更熟悉,但我看到node.js中的Lambda函数比Java更受欢迎。基于Java和基于nodejs的lambda函数之间是否有任何性能差异?

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?

推荐答案

虽然Java的启动时间较慢,但它的运行时性能较差比node.js或Python好多了。这意味着Java Lambda函数在以下情况下有意义:

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. 定期调用它们 - AWS Lambda将重复使用它的初始化容器,您可以从没有冷启动延迟的更好性能中受益

  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

和/或


  1. 它们具有较长的运行时间 - 如果您的功能正在运行,例如1或2分钟,如果函数本身运行速度比node.js快一个数量级,你真的不关心启动5秒。

  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

您可能需要查看此github项目,以比较冷启动时间。

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

Java糟糕的冷启动的一个重要因素可能是Java项目通常比例如大得多node.js函数。无论如何,您应该始终尽量保持功能尽可能小,以减少初始延迟。

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.

当然,性能不应该是选择编程时的唯一因素语言。我个人认为node.js在工作时非常方便。使用JSON数据,这就是我在大多数函数中使用它的原因。

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.

这篇关于在node.js / Java中编写的AWS Lambda函数是否存在任何性能/功能差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆