SlideShare a Scribd company logo
Server side Javascript environment
What is node.js? Why another server side technology? Node.js is a server-side JavaScript environment that uses an asynchronous event-driven model. This allows Node.js to get excellent performance based on the architectures of many Internet applications. Most regular Web Servers like Apache uses OS threads for request handling. That means that every request the server handles will spawn a OS thread and the web server won't release the thread until the request finish. Most of the time OS threads wait till some I/O operation finish: var result = query("select * from users"); for(user in result){      //You get the idea } In this case the OS thread just sits and waits the I/O operation returns to resume the flow. Every OS thread takes some memory, so regular servers can't handle many simultaneous connections without penalizing the system performance.
node.js carachteristics Implemented on top of the V8 js engine (Chromium and Google Chrome engine). Programs are written in plain old javascript, we use the same language for client and server (Die Ruby Die!) Does I/O better: query("select * from users", function(data, status){   //Do something really cool with users }); Files I/O and db queries are non-blocking Great performance even handling a big number of users It gets better every time google improves V8 It has his own package manager called npm (node package manager)
Alternatives Ruby Event Machine Python Twisted
hands on code: hello world! <?php       //helloworld.php      echo &quot;hello&quot;;      sleep(2);      echo &quot;world!&quot;; ?> //helloworld.js setTimeout(function(){      console.log(&quot;world!&quot;); }, 2000); console.log(&quot;hello&quot;); There is no waisted time on the node program, the thread is idle not waiting
hands on code: http server var http = require(&quot;http&quot;) ; var server = http.createServer(function(req, res){      res.writeHead(200, {&quot;content-type&quot;:&quot;text/plain&quot;});      res.end(&quot;Hello World!\n&quot;); }).listen(8000); Headers of the request are: HTTP/1.1 200 OK content-type: text/plain Connection: keep-alive Transfer-Encoding: chunked
hands on code: not only http var net = require(&quot;net&quot;) ; net.createServer(function(socket){      socket.on(&quot;data&quot;, function(data){        socket.write(data);      }); }).listen(8000);
hands on code: telnet chat var net = require(&quot;net&quot;); var clients = []; net.createServer(function(socket){    clients.push(socket);         socket.on(&quot;data&quot;, function(data){      for(var i = 0; i < clients.length; i++){              if(clients[i] == socket) continue;        clients[i].write(data);                  }        });         socket.on(&quot;end&quot;, function(){      var index = clients.indexOf(socket);      clients.splice(index, 1);    });   }).listen(8000);
hands on code: Async I/O var fs = require(&quot;fs&quot;)    , sys = require(&quot;sys&quot;);; fs.readFile(&quot;/home/cherta/workspace/samples/foo.txt&quot;, function(err, data){      if(err) throw err;      sys.puts(data) }); console.log(&quot;Antes de foo?&quot;);
What is node.js? It's a set of tools and libraries living on top of the V8. What is not node.js? A super framework that would change your life. Assuming that your life will change for a crappy piece of software
Working on top of node There are killer frameworks that will make your life easier using node. Express web framework Socket IO
Express Web framework working on top of node.js High Performance Template engines support (jade, ejs) CSS engines support (sass, less, stylus) Partials support  var app = express.createServer(); app.get('/', function(req, res){      res.send('Hello World'); }); app.listen(3000);
Socket I/O Socket.IO is a Node.JS project that makes WebSockets and realtime possible in all browsers. It also enhances WebSockets by providing built-in multiplexing, horizontal scalability, automatic JSON encoding/decoding, and more.
gracias

More Related Content

PPT
Node.js Basics
PPTX
Responsive web designing ppt(1)
PPTX
NodeJS - Server Side JS
PPT
Node.js Express Framework
PDF
Nodejs presentation
PDF
Angular
PPTX
Introduction Node.js
PPTX
Introduction To Mobile Application Development
Node.js Basics
Responsive web designing ppt(1)
NodeJS - Server Side JS
Node.js Express Framework
Nodejs presentation
Angular
Introduction Node.js
Introduction To Mobile Application Development

What's hot (20)

PPTX
Introduction to mobile application development
PDF
Mobile Application Security
PPTX
Express js
PPTX
Angular Best Practices To Build Clean and Performant Web Applications
PPT
Android Training Syllabus - Course
PDF
Laravel presentation
PPTX
Flutter 3
PPT
9781305078444 ppt ch02
PPTX
Android ppt
PPTX
Introduction to React JS
PPTX
Introduction to Node.js
PPTX
Mobile Application Security
PPSX
Advanced Web Development in PHP - Understanding REST API
PPT
Sandbox Technology in AntiVirus
PPTX
Node.js Express
PDF
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
PPT
iOS Introduction For Very Beginners
PPTX
Android Security
Introduction to mobile application development
Mobile Application Security
Express js
Angular Best Practices To Build Clean and Performant Web Applications
Android Training Syllabus - Course
Laravel presentation
Flutter 3
9781305078444 ppt ch02
Android ppt
Introduction to React JS
Introduction to Node.js
Mobile Application Security
Advanced Web Development in PHP - Understanding REST API
Sandbox Technology in AntiVirus
Node.js Express
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
iOS Introduction For Very Beginners
Android Security
Ad

Viewers also liked (20)

PPTX
Introduction to Node.js
PDF
Introduction to Nodejs
PDF
NodeJS for Beginner
PDF
Nodejs Explained with Examples
PDF
Anatomy of a Modern Node.js Application Architecture
PDF
Node Foundation Membership Overview 20160907
PDF
KEY
Introduction to node.js
PDF
reveal.js 3.0.0
PDF
Modern UI Development With Node.js
PDF
The Enterprise Case for Node.js
PDF
Architecting large Node.js applications
KEY
Node.js - Best practices
PPTX
Nodejs intro
PDF
Non-blocking I/O, Event loops and node.js
PPTX
Node js introduction
PPT
Presentación Juego para el plan ceibal
PDF
UX en proyectos de moove-it
ODP
Node js presentation
PDF
Wait queue
Introduction to Node.js
Introduction to Nodejs
NodeJS for Beginner
Nodejs Explained with Examples
Anatomy of a Modern Node.js Application Architecture
Node Foundation Membership Overview 20160907
Introduction to node.js
reveal.js 3.0.0
Modern UI Development With Node.js
The Enterprise Case for Node.js
Architecting large Node.js applications
Node.js - Best practices
Nodejs intro
Non-blocking I/O, Event loops and node.js
Node js introduction
Presentación Juego para el plan ceibal
UX en proyectos de moove-it
Node js presentation
Wait queue
Ad

Similar to Node js presentation (20)

PPTX
GeekCampSG - Nodejs , Websockets and Realtime Web
PPTX
ODP
Introduce about Nodejs - duyetdev.com
PDF
Developing realtime apps with Drupal and NodeJS
PPTX
PDF
Why Nodejs Guilin Shanghai
PDF
Why Node.js
PDF
Nodejs - A quick tour (v6)
PPTX
NodeJS guide for beginners
PPTX
PDF
Introduction to Node.js: What, why and how?
KEY
Node.js - A practical introduction (v2)
PPTX
introduction to node.js
PPTX
Beginners Node.js
PDF
Workshop 4: NodeJS. Express Framework & MongoDB.
PDF
Nodejs - A quick tour (v5)
PDF
Intro to node.js - Ran Mizrahi (27/8/2014)
PDF
Intro to node.js - Ran Mizrahi (28/8/14)
PPT
PPTX
An overview of node.js
GeekCampSG - Nodejs , Websockets and Realtime Web
Introduce about Nodejs - duyetdev.com
Developing realtime apps with Drupal and NodeJS
Why Nodejs Guilin Shanghai
Why Node.js
Nodejs - A quick tour (v6)
NodeJS guide for beginners
Introduction to Node.js: What, why and how?
Node.js - A practical introduction (v2)
introduction to node.js
Beginners Node.js
Workshop 4: NodeJS. Express Framework & MongoDB.
Nodejs - A quick tour (v5)
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (28/8/14)
An overview of node.js

Node js presentation

  • 2. What is node.js? Why another server side technology? Node.js is a server-side JavaScript environment that uses an asynchronous event-driven model. This allows Node.js to get excellent performance based on the architectures of many Internet applications. Most regular Web Servers like Apache uses OS threads for request handling. That means that every request the server handles will spawn a OS thread and the web server won't release the thread until the request finish. Most of the time OS threads wait till some I/O operation finish: var result = query(&quot;select * from users&quot;); for(user in result){      //You get the idea } In this case the OS thread just sits and waits the I/O operation returns to resume the flow. Every OS thread takes some memory, so regular servers can't handle many simultaneous connections without penalizing the system performance.
  • 3. node.js carachteristics Implemented on top of the V8 js engine (Chromium and Google Chrome engine). Programs are written in plain old javascript, we use the same language for client and server (Die Ruby Die!) Does I/O better: query(&quot;select * from users&quot;, function(data, status){   //Do something really cool with users }); Files I/O and db queries are non-blocking Great performance even handling a big number of users It gets better every time google improves V8 It has his own package manager called npm (node package manager)
  • 4. Alternatives Ruby Event Machine Python Twisted
  • 5. hands on code: hello world! <?php       //helloworld.php      echo &quot;hello&quot;;      sleep(2);      echo &quot;world!&quot;; ?> //helloworld.js setTimeout(function(){      console.log(&quot;world!&quot;); }, 2000); console.log(&quot;hello&quot;); There is no waisted time on the node program, the thread is idle not waiting
  • 6. hands on code: http server var http = require(&quot;http&quot;) ; var server = http.createServer(function(req, res){      res.writeHead(200, {&quot;content-type&quot;:&quot;text/plain&quot;});      res.end(&quot;Hello World!\n&quot;); }).listen(8000); Headers of the request are: HTTP/1.1 200 OK content-type: text/plain Connection: keep-alive Transfer-Encoding: chunked
  • 7. hands on code: not only http var net = require(&quot;net&quot;) ; net.createServer(function(socket){      socket.on(&quot;data&quot;, function(data){        socket.write(data);      }); }).listen(8000);
  • 8. hands on code: telnet chat var net = require(&quot;net&quot;); var clients = []; net.createServer(function(socket){    clients.push(socket);         socket.on(&quot;data&quot;, function(data){      for(var i = 0; i < clients.length; i++){              if(clients[i] == socket) continue;        clients[i].write(data);                  }        });         socket.on(&quot;end&quot;, function(){      var index = clients.indexOf(socket);      clients.splice(index, 1);    });   }).listen(8000);
  • 9. hands on code: Async I/O var fs = require(&quot;fs&quot;)   , sys = require(&quot;sys&quot;);; fs.readFile(&quot;/home/cherta/workspace/samples/foo.txt&quot;, function(err, data){     if(err) throw err;     sys.puts(data) }); console.log(&quot;Antes de foo?&quot;);
  • 10. What is node.js? It's a set of tools and libraries living on top of the V8. What is not node.js? A super framework that would change your life. Assuming that your life will change for a crappy piece of software
  • 11. Working on top of node There are killer frameworks that will make your life easier using node. Express web framework Socket IO
  • 12. Express Web framework working on top of node.js High Performance Template engines support (jade, ejs) CSS engines support (sass, less, stylus) Partials support  var app = express.createServer(); app.get('/', function(req, res){     res.send('Hello World'); }); app.listen(3000);
  • 13. Socket I/O Socket.IO is a Node.JS project that makes WebSockets and realtime possible in all browsers. It also enhances WebSockets by providing built-in multiplexing, horizontal scalability, automatic JSON encoding/decoding, and more.