Multi-core HTTP Server with Node.js
>> "While single-process performance is quite good, eventually one CPU is not going to be enough;"
Every article on this sort of thing seems to just gloss over this part. Why isn't one CPU enough? What is using it? Serving static files certainly won't. Doing simple things won't...
Does anyone have any use cases / experience for when this was the case? :/
edit: Fine downmodding fanboys. I get it. Use whatever you like. Meh
"However, rather than accepting connections using this socket, it is passed off to some number of child processes using net.Stream.write() (under the covers this uses sendmsg(2) and FDs are delivered using recvmsg(2)). Each of these processes in turn inserts the received file descriptor into its event loop and accepts incoming connections as they become available. The OS kernel itself is responsible for load balancing connections across processes."
Racing (ie thread-safe) accept() is a really good way to improve server throughput. Epoll is also awesome for being thread-safe.
From the day node.js was released you could run multiple instances on different ports and stick a load balancer in front of it. Even now, I think that is a healthier option than baking the number of processes into the script itself.
Why are they using multiple processes rather than multiple worker threads? IPC is much costlier than using shared memory, even if it's just passing the initial state.
Isn't this tremendously inefficient compared to just running Apache, nginx or whatever floats your boat? Both of them thread perfectly across SMP systems. While it's an interesting implementation, I completely fail to see the point of even using it. Does anyone have any sane usage scenarios they could share?
Why not nginx? ^_^
It is so inadequate to use things like JVM or V8 to serve static content.
Btw, is there any cool-web-server project for Flash - yet another artificial blob (or to be more correct - tumour) in an OS? ^_^
And of course there should be some dynamic web server written on PHP! (yes, you can run it standalone)