Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js and V8 garbage collection

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?

like image 829
ming_codes Avatar asked Apr 09 '11 05:04

ming_codes


1 Answers

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.

like image 190
Erik Corry Avatar answered Oct 12 '22 23:10

Erik Corry