Node.js的可伸缩性是否因高负载下的垃圾回收而受到影响? [英] Does Node.js scalability suffer because of garbage collection when under high load?

查看:135
本文介绍了Node.js的可伸缩性是否因高负载下的垃圾回收而受到影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然Node.js是相当热门的话题,但我偶然发现,由于其垃圾收集模型(http://amix.dk/blog/post),Node.js可能不适合实时应用程序/ 19577)。并且,一些基准测试显示,与RingoJS相比,Node.js响应速度较慢(http://hns.github.com/2010/09/29/benchmark2.html)。



目前,Node.js被绑定到V8 JavaScript引擎,它使用世代停止的GC。

那么,当传入的请求很大时Node.js会被破坏吗?
如果有实际的生产统计数据,那会更好。



谢谢

解决方案

垃圾收集的成本取决于堆中的对象数量,特别是长寿命对象的数量。你拥有的越多,在GC上花的时间就越多。



是的,如果堆很大,V8目前可能会有一些相当大的GC暂停。这听起来像V8团队正在努力通过分散工作来最大限度地减少每个GC暂停的成本。您可以通过从 - trace-gc 开始,在自己的节点程序中看到GC的开销。



对于许多应用程序来说,GC的成本被日益优化的优化编译器所抵消。我建议尝试一个简单的程序,并测量V8报告的GC成本以及测量客户端到客户端的延迟。我发现当客户通过开放的互联网连接时,GC成本几乎完全可以忽略。


Though Node.js is pretty hot topic, I happens to find that it is reported Node.js might not be appropriate for real-time application due to its Garbage Collection model (http://amix.dk/blog/post/19577). And, some benchmark shows that Node.js responds slow compared to RingoJS(http://hns.github.com/2010/09/29/benchmark2.html).

For the time being, Node.js is bound to V8 JavaScript engine which use generational stop-the-world GC.

So, would Node.js be busted when incoming requests are massive? If there is real production statistics, that would be better.

Thanks

解决方案

The cost of garbage collection depends on the number of objects in the heap, particularly the number of long-lived objects. The more you have, the more time will be spent in GC.

Yes, V8 currently can take some sizable GC pauses sometimes if the heap is large. It sounds like the V8 team is working on minimizing the cost of each GC pause by spreading the work out. You can see the cost of GC in your own node programs by starting it with --trace-gc.

For many applications, the cost of GC is offset by the increasingly excellent optimizing compiler. I'd suggest trying a simple program and measuring both the cost of GC as reported by V8 as well as measuring the client to client latency. I've found the GC costs to be almost completely ignorable when the clients are connecting over the open Internet.

这篇关于Node.js的可伸缩性是否因高负载下的垃圾回收而受到影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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