NodeJS overview
-
Upload
trukhin-roman -
Category
Technology
-
view
2.305 -
download
0
description
Transcript of NodeJS overview
NodeJS
Milestones
● Server-side Javascript based on Google V8
● Non-blocking Input/Output event model
● 100% CPU using: one process - one thread - one core
Google V8
● V8 JavaScript VM is used in Google Chrome
● No JIT, all JavaScript is compiled to assembler
● Hidden classes optimization from Self (V8 does not dynamically lookup access properties, instead it uses hidden classes that are created behind the scene)
● Improved garbage collector
Non-blocking I/O
The non-blocking nature makes node.js a good fit for comet and next generation realtime web-applications
nginx: non-blockingapache: threadednon-blocking can handle more requests-per-second and uses a lot less memory
NodeJS Perks: front- and backend
● One Javascript - different approaches
● Common libs
● Unit-tests for both sides
NodeJS Perks: Frameworks
Native example:
var http = require('http');http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'
});res.end('Hello World\n');
}).listen(3000, '127.0.0.1');
ExpressJS:
var app = express.createServer();app.get('/', function(req, res){
res.send('Hello World');});app.listen(3000);
NodeJS Perks: Comet
Comet is a web application model in which a long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it.
● Comet servers need to have a lot of open connections● One thread-per-connection does not scale● The solution is to use event based servers● It’s only possible to create event based servers in
node.js
NodeJS Weaknesses
● Due to Javascript flexible nature it's hard to locate mistakes
● Strict convention rules are highly recommended
● One process serve plenty requests: so, mistake in one request may "freeze" other.
● Non-trivial garbage collector (closures, long-term processes)
● Strange open-source community (no standards)
● No backward compatibility
NodeJS Scalability
NodeJS Scalability
Resources
1. http://nodejs.org2. www.nodebeginner.ru3. http://pacemaker.pp.ua/presentations/Yura_Bogdanov-nodejs_inside_tactoom.ppt4. http://code.google.com/p/v8/