2. Node.js is a software platform for scalable server-side and
networking applications. Node.js applications are written in
JavaScript, and can be run within the Node.js runtime on
Windows, Mac OS X and Linux with no changes.
Node.js applications are designed to maximize throughput
and efficiency, using non-blocking I/O and asynchronous
events. Node.js applications run single-threaded, although
Node uses multiple threads for file and network events.
Node.js internally uses the Google V8 JavaScript engine to
execute code, and a large percentage of the basic modules
are written in JavaScript. Node.js contains a built-in HTTP
server library, making it possible to run a web server without
Apache or Lighttpd.
-Wikipedia
4. Many web applications have code
like this:
var result =
db.query("select * from T");
// use result
What is the software doing while it
queries the database?
10. Apache vs NGINX
The difference?
Apache uses one thread per
Connection.
NGINX doesn’t use threads. It uses
an event loop.
11. Code like this
var result = db.query("select..");
// use result
either blocks the entire process or
implies multiple execution stacks.
12. But a line of code like this
db.query("select..", function (result) {
// use result
});
allows the program to return to the
event loop immediately.
13. So why isn’t everyone using event
loops, callbacks, and non-blocking
I/O?
For reasons both cultural and
infrastructural.