Listening to Glenn Block talk about node.js at Technology and Friends, there’s something interesting about the philosophy behind node.js.
Threads are hard. Threads include overhead, but more significantly, using them requires the developer to hold more stuff in his head. Node.js has a philosophy that leads to asynchronous processing without multiple threads.
Glenn explains how the node.js server is single-threaded, but all the APIs are asynchronous, using callbacks. All the incoming requests go onto one queue, and then whenever processing a request requires calling a service or doing I/O or anything that may take some time, that call is executed asynchronously and the callback goes onto the queue. Because there’s only one thread, developers don’t have to think about multithreading. Because of the asynchronous APIs with callbacks, the single thread doesn’t block waiting for anything. Concurrent performance without threading.