Tuesday 15 May 2012

Node.js workers, do they have independent event loops? -



Node.js workers, do they have independent event loops? -

i testing cluster module simple webapp , have come across behaviour doesn't match way thought node works.

my app has express router invokes blocking fibonacci service (it doesn't utilize nexttick nor setimmediate).

scenario 1 - no workers: expected first request blocks event loop waiting result , other requests don't execute.

scenario 2 - workers: start n workers , surprisingly, can execute n requests simultaneously. thought since master process , workers share same socket, share same event loop. can explain why can execute in paralell?

the main thought of workers have different event loops code can execute in parallel. why see multiple requests executing simultaneously.

node.js event-loop

No comments:

Post a Comment