Is it expensive/efficient to send data between processes in Node?

后端 未结 2 1879
故里飘歌
故里飘歌 2020-12-13 17:06

Node allows you to spawn child processes and send data between them. You could use it do execute some blocking code for example.

Documentation says \"These child No

2条回答
  •  隐瞒了意图╮
    2020-12-13 17:20

    This really depends on your server resources and the number of nodes you need to spin up.

    As a rule of thumb:

    • Try reusing running children as much as possible - this will save you 30ms start up time
    • Do not start unlimited number of children (1 per request for instance) - you will not run out of RAM

    The messaging itself it relatively fast i believe. Would be great to see some metrics though.

    Also, note that if you have single CPU or running a cluster (using all available cores) it doesn't make much sense. You still have limited CPU capacity and switching context is more expensive than running single process.

提交回复
热议问题