Question

If you run an I/O intensive task in Node.js, like some async database operation, using node-fibers, is it blocking?

I haven't used node-fibers yet b/c it seems that -- if used in code that processes an HTTP request in which some long normally-non-blocking I/O code is run -- it would now prevent other requests from accessing your app. Is this true or not? A little detail on why it's true/false would be very helpful as well.

Was it helpful?

Solution

Fibers allow the programmer write "thread-like" blocking-statement JavaScript code. But it's implementation is not blocking, the code is equivalent to the node.js async event code. Laverdets implementation pauses the fiber execution at some point, quite like the async node.js model, and can be resumed at a later time.

Fibers are more of syntactic sugar, they do not change the node.js async model. The only difference is that fibers are creating different execution stacks (if i am correct), which is a slight overhead to normal nodejs async code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top