In PHP (or Java/ASP.NET/Ruby) based webservers every client request is instantiated on a new thread. But in Node.js all the clients run on the same thread (they can even share the same variables!) I understand that I/O operations are event based so they don't block the main thread loop.
What I don't understand is WHY the author of Node chose it to be single threaded? It makes things difficult. For example I can't run a CPU intensive function because it blocks the main thread (and new client requests are blocked) so I need to spawn a process (which means I need to create a separate JavaScript file and execute another node process on it). However in PHP cpu intensive tasks do not block other clients because as I mentioned each client is on a different thread. What are its advantages compared to multi-threaded web servers?
NodeJs was built with the intention of supporting asynchronous operations.... and the fact is that the asynchronous operations have better performance and scalability when they are single-threaded over multi-threaded. This is the reason the NodeJs is single threaded.
Fact: PHP and ASP.NET are single-threaded (I don't know about Ruby, though). Every request will spawn a new instance of the whole program, either as new process or inside the VM. That's quite a lot of overhead!
Node.JS is not single-threaded. It is comparable to a Java server, but with a twist. In fact, for every I/O operation, a new thread is automatically spawned. That's possible because of the asynchronicity and the internal event loop. This kind of architecture results in a very very low overhead and very good performance for I/O with many concurrent clients.
On top of that, Node.JS can be scaled easily. There is the cluster module, which allows you to spawn several processes you control (with whatever code you want, you don't even need a separate JS file), which are automatically connected via IPC channels.
Sidenote: JS is not made for number crunching. If you need to do heavy calculations, you should use a different language (use the right tool for the right job), for example Rust. Node.JS has its forte in I/O!
Read more about the Event Loop:
Tiaan
Watch Ryan Dahl's original presentation where he gives his motivation for the choice.