通过永久运行风帆或直接用 node app.js --prod
调用它,根据 htop
我有一个4子进程看起来像它下面的克隆 .
如果我省略了 --prod
参数,我会获得相同数量的grunt进程 . 如您所见,它们都具有相同的内存量,不同的PID和不同的TIME读数 .
我很确定它不会自动聚类,或者是它?这是一个单核机器(虚拟),所以我不知道这些进程是什么,或者它是htop中的错误?
根据这个问题htop-showing-multiple-java-processes-with-different-pids?rq=1
htop将线程显示为不同的进程,但不是节点单线程?如果这些是他们来自的线程?
1 回答
您使用htop看到的线程是用户态线程(用户的线程),但是当您以集群模式运行应用程序(例如4个实例)时,它会生成内核线程 . more on user threads
当你隐藏用户态线程时,你所看到的就是内核线程 . 在集群模式下运行应用程序时,你将创建一个应用程序的多个内核线程 . 对于每个应用程序的内核线程,有几个与之关联的用户态线程 .
(for htop you can hide userland thread by F2 and display options)
请参阅屏幕截图以获得解释 .
four instances of my app in cluster mode since number of cores==4
ps commands showing kernel threads only
htop showing kernel threads only
htop showing kernel threads along with userland threads
In last screenshot you see a few kernel and userland's threads but there are more. I mean for each kernel thread there are some userland's thread associated with it.