Clojure vs节点。js内存消耗

时间:2021-01-15 22:47:42

Recently I've been stumbling upon a lot of benchmarks between Node.js and Clojure, such as this, and this, and this. It seems to me, that compared to languages like Ruby, both Node.js and Clojure are about equally fast (which means a lot faster).

最近,我在Node之间偶然发现了许多基准。js和Clojure,比如这个,这个,还有这个。在我看来,与Ruby之类的语言相比,两者都是节点。js和Clojure的速度一样快(这意味着更快)。

The question is, how does Clojure compare to Node.js in terms of RAM consumption? Say that I was about to write a simple live chat app.

问题是,Clojure如何与节点进行比较。在RAM的消耗方面?假设我要写一个简单的实时聊天应用。

If I was about to compare Rails vs Node.js, I can basically expect Node.js to be 100 times faster and take 10 times less memory than Rails ... but how does Clojure fit in here?

如果我要比较Rails和Node。js,我基本上可以预期Node。js要比Rails快100倍,占用的内存也要少10倍……但是Clojure是如何适应这里的呢?

How would Clojure compare here in terms of memory consumption? Can I expect it to take a lot more memory than Node.js, because it is running on the JVM? Or is this just a stereotype that isn't true anymore?

Clojure在内存消耗方面有何不同?我能指望它比Node占用更多的内存吗?因为它在JVM上运行?或者,这只是一种不再真实的刻板印象?

1 个解决方案

#1


4  

For a simple application on modern hardware, you should have no memory usage issues with either Node.js or Clojure.

对于现代硬件上的简单应用程序,任何一个节点都不存在内存使用问题。js或Clojure。

Of course, as Niklas points out it will ultimately depend on what frameworks you use and how well written your app is.

当然,正如Niklas所指出的,它最终将取决于您使用的框架以及您的应用程序编写得有多好。

Clojure has quite a significant base memory requirement (because the java runtime environment / JVM is pretty large), but I've found it to be pretty memory efficient beyond than point - Clojure objects are just Java objects under the hood so that probably shouldn't be too surprising.

Clojure具有相当重要的基本内存需求(因为java运行时环境/ JVM相当大),但我发现它比point更节省内存——Clojure对象只是隐藏在底层的java对象,所以这不太奇怪。

It's also worth noting that directly measuring the memory usage of a JVM app is usually misleading, since the JVM typically pre-allocates more memory than it needs and only garbage collects in a lazy (as needed) fashion. So while the apparent total memory usage looks high, the actual working set can be quite small (which is what you really care about for performance purposes).

同样值得注意的是,直接度量JVM应用程序的内存使用通常具有误导性,因为JVM通常预先分配比它需要的更多的内存,并且只以惰性(根据需要)方式收集垃圾。因此,虽然明显的总内存使用量看起来很高,但是实际的工作集可能非常小(这是您真正关心的性能目的)。

#1


4  

For a simple application on modern hardware, you should have no memory usage issues with either Node.js or Clojure.

对于现代硬件上的简单应用程序,任何一个节点都不存在内存使用问题。js或Clojure。

Of course, as Niklas points out it will ultimately depend on what frameworks you use and how well written your app is.

当然,正如Niklas所指出的,它最终将取决于您使用的框架以及您的应用程序编写得有多好。

Clojure has quite a significant base memory requirement (because the java runtime environment / JVM is pretty large), but I've found it to be pretty memory efficient beyond than point - Clojure objects are just Java objects under the hood so that probably shouldn't be too surprising.

Clojure具有相当重要的基本内存需求(因为java运行时环境/ JVM相当大),但我发现它比point更节省内存——Clojure对象只是隐藏在底层的java对象,所以这不太奇怪。

It's also worth noting that directly measuring the memory usage of a JVM app is usually misleading, since the JVM typically pre-allocates more memory than it needs and only garbage collects in a lazy (as needed) fashion. So while the apparent total memory usage looks high, the actual working set can be quite small (which is what you really care about for performance purposes).

同样值得注意的是,直接度量JVM应用程序的内存使用通常具有误导性,因为JVM通常预先分配比它需要的更多的内存,并且只以惰性(根据需要)方式收集垃圾。因此,虽然明显的总内存使用量看起来很高,但是实际的工作集可能非常小(这是您真正关心的性能目的)。