进程的好处就是一旦一个进程死了,整个服务器不受影响继续运行。这当然是更加安全的。但是问题是怎么就能死了呢?作为一个程序员,你写的程序上了线还能死掉,这是一种侮辱啊。
线程当然没有进程可靠,但是线程的系统开销要小多了。当然,node.js表示,谁在乎这个?你爱用啥就用啥。
You can start new processes via child_process.fork() these other processes will be scheduled in parallel. For load balancing incoming connections across multiple processes use the cluster module.
接着又说:
These child Nodes are still whole new instances of V8. Assume at least 30ms startup and 10mb memory for each new Node. That is, you cannot create many thousands of them.
如果用进程,请想一想如果你的服务器有成千上万的用户接入,结果是什么?比死掉好不到那里去。
线程当然没有进程可靠,但是线程的系统开销要小多了。当然,node.js表示,谁在乎这个?你爱用啥就用啥。
You can start new processes via child_process.fork() these other processes will be scheduled in parallel. For load balancing incoming connections across multiple processes use the cluster module.
接着又说:
These child Nodes are still whole new instances of V8. Assume at least 30ms startup and 10mb memory for each new Node. That is, you cannot create many thousands of them.
如果用进程,请想一想如果你的服务器有成千上万的用户接入,结果是什么?比死掉好不到那里去。