Sunday, June 15, 2014

Node.js pluses : it's event based, and scalable thus because...

http://code.tutsplus.com/tutorials/learning-server-side-javascript-with-nodejs--net-10044
Web servers like Apache that are used to serve PHP and other CGI scripts are thread based because they spawn a system thread for every incoming request. While this is fine for many applications, the thread based model does not scale well with many long-lived connections like you would need in order to serve real-time applications like Friendfeed or Google Wave.
"Every I/O operation in Node.js is asynchronous..."
Node.js, uses an event loop instead of threads, and is able to scale to millions of concurrent connections. It takes advantage of the fact that servers spend most of their time waiting for I/O operations, like reading a file from a hard drive, accessing an external web service or waiting for a file to finish being uploaded, because these operations are much slower than in memory operations. Every I/O operation in Node.js is asynchronous, meaning that the server can continue to process incoming requests while the I/O operation takes place.

No comments:

Post a Comment