Reference: Http://stackoverflow.com/questions/15349733/setimmediate-vs-nexttick
Setimmediate occurs after an I/O event has been triggered on the event queue, Process.nexttick before the event queue, and occurs after the current function has ended.
So, if you're going to interrupt a long run, using a recursive CPU task, you can use setimmediate instead of Process.nexttick to insert the next iteration, otherwise any I/O event callbacks will not have any chance of being invoked during the iteration.
Other than that:
The callback function passed to Process.nexttick is usually called at the end of the execution event stream, so it is best for synchronization operations as fast as possible. If no check is made, this consumes the event loop and prevents I/O from occurring. Setimmediates inserts the queue in the order in which it was created, and pops up during each iteration. This is very different from Process.nexttick, where Process.nexttick executes the process.maxtickdepth queue callback function at each iteration. Setimmediate will yield to the event loop after triggering the queue callback function to ensure that I/O is not consumed.
The difference between Setimmediate vs. Nexttick