My app uses node.js, because node.js and Mongo are a perfect match made in heaven. But I am wondering about this:
My server app runs in a single process. Node.js is async, but single-threaded, would that mean that node will not send two queries at once to the mongo server?
On the server, Mongod runs with 5 worker processes. Are those necessary? Can I just reduce it to one, and it works just as fine? (And if so, how?)
Or maybe there's a way to make my node app run on several processes, effectively.
would that mean that node will not send two queries at once to the mongo server?
Indeed, Node will SEND requests synchronously to mongo. Sending requests however is done in a heartbeat (usually low milliseconds range) .
The number-crunshing stuff happens at the mongo-side, which has to do the hard stuff of making a response. This is what the mongo worker processes are for, and is done in parallel (5 workers equals 5 threads) NOTE: Node will not block while mongo is calculating this repsonse
In the end mongo sends it's response(s) which you capture in node using a (async) callback.
p.s: so imo no need to cluster just yet. It's nice asynchronous as it is. (Besides hitting mongo with lots of requests is more than likely IO bound, so 'clustering' it so other cpu's can share the load isn't going to be much help in that case.
hth
this should basically answer your question:
http://nodejs.org/api/cluster.html
if it doesnt, well it enables you to create child processes for your node app that run specific parts of your code.