简体   繁体   中英

handling nodejs http requests in a separate process

I want to handle specific http requests in a child process. These requests being identified by the URL path. There are several examples in the node documentation and elsewhere online that almost do this or that simply do not work.

The reason for this is that the main server must be reliable and that certain requests may be handled by code that is not necessarily of the same quality. For this reason the entire request should be handed over to an external process that can be resurrected if it dies.

Ideally the external process should look as much like a normal node http server as possible and the connection between parent and child processes should not be over a socket.

It seems that the fork function and messages might do what I require but I cannot see any way to pass the request and response to the child process for handling.

Have you looked at nodejs cluster module ?

It is not for specific requests but basically the master forks multiple workers that can then handle http requests (1 worker per cpu core in general). If the worker dies, the master forks a new one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM