Can someone correct me if I'm wrong here (Node vs Apache for lots of requests)
My general understanding (which is probably wrong) goes like this. Please correct me if I'm wrong!
Since node uses a single thread to handle many requests, it is better suited to handle a lot of requests because a new thread is not needed for every request and thus it can yield more performance. So if I was developing a single page web app that does a lot of AJAX in the background as an example, node would likely be a better candidate as it would be more efficient at relaying information from a database to the client, instead of a crazy amount of threads starting making the CPU slower (inefficient?).
So in this case it would be bad to do a lot of CPU work because requests will be blocked until the CPU on the thread is in an idle state.
I don't understand what the advantage of not doing servers this way is. From my last paragraph, it might make sense that that statement doesn't hold true for Apache, which would mean that you can do more CPU intensive stuff, because the other threads will still be responsive enough to handle their respective connections due to the CPU context switching. Is this true? If so, then I finally get it! Woohoo!
Posted Apr 3, 2015, 11:00 AM UTC
Apache uses thread pools, so the threads are already there (it starts them when apache starts and can change the size of the pool on demand). Also, threads aren't necessarily a bad thing. node uses threads for it's async i/o (libuv).
Though, comparing node and apache is like comparing apples and oranges. Yeah they both can serve web applications, but they are completely different.
The good thing is that both node and apache are free software so you can try both and compare them with the types of workloads you're expecting.