且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Node.js和V8垃圾收集

更新时间:2023-09-26 19:20:58

是否可以接受取决于您的应用程序和您的堆大小。 Big Gc大约是1.3MB每兆字节。因人而异。约一半的压缩气相色谱。 10个左右的GC大。 3个左右的大型气相色谱仪正在紧缩。使用V8标志--trace-gc来记录GC。我们已经做了一些减少停顿的工作。没有承诺,没有时间表。请参阅V8回购中的branches / experimental / gc。

Here's what's I've read so far, and correct me if I'm wrong:

  1. Node.js is based on V8 JavaScript engine.
  2. V8 JavaScript engine implements stop-the-world garbage collection

Which..causes Node.js to sometimes completely shutdown for a few seconds to a few minutes to handle garbage collection.

If this is running for production code, that's a few seconds for 10,000 users.

Is this really acceptable in production environment?

Whether it is acceptable depends on your application and your heap size. Big Gc is around 1.3ms per Mbyte. YMMV. About half that for a compacting GC. Around 1 GC in 10 is big. Around 1 big GC in 3 is compacting. Use V8 flag --trace-gc to log GCs. We have done some work on reducing pauses. No promises, no timetables. See branches/experimental/gc in V8 repo.