Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Node.js Introduction

7,867 views

Published on

in Joomladay 2013 Bangkok

Published in: Technology
  • Dating for everyone is here: ❤❤❤ http://bit.ly/2Q98JRS ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating direct: ❤❤❤ http://bit.ly/2Q98JRS ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Hi there! Get Your Professional Job-Winning Resume Here - Check our website! http://bit.ly/resumpro
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Node.js Introduction

  1. 1. node.js introduction of server side javascript Saturday, November 23, 13
  2. 2. Sira Sujjinanont @hunt Managing Director Webiz Co.,Ltd. CTO Jitta.com 15 years in Web development Saturday, November 23, 13
  3. 3. Web Development Journey • Static HTML • PERL/CGI (2 years) • PHP (11 years) • • • CMS > Drupal, Wordpress, Joomla Framework > Yii, Zend, CodeIgniter, … What’s next?!? Saturday, November 23, 13
  4. 4. PHP bad parts • Consume a lot of memories • Cannot do Realtime Application • Cannot deal direct with protocol layer • No parallel processing Saturday, November 23, 13
  5. 5. What I need in the next? • Easy to learn (for me and for my team) • Fast / Scalability • Allow us to dig deep in engineering • New technology! New boundary! • Open source with great community Saturday, November 23, 13
  6. 6. And node.js came up! (server-side javascript) but we need to dig it deep!! Saturday, November 23, 13
  7. 7. Why Javascript? • Easy to learn and understanding! • Front-end coder can do backend immediately! • Javascript Engine war! (huge changed on web industry) • Non-blocking I/O • One language on both front and back!!! Saturday, November 23, 13
  8. 8. Server-side javascript • Netscape LiveWrite 1996 • Rhino 1997 • and over 50 platforms! Saturday, November 23, 13
  9. 9. Many problems! • Slow engines • Lag of interest in Javascript language (until 2005… ajax trend!) • Great competitors platform and language Saturday, November 23, 13
  10. 10. • Created by Ryan Dahl in 2009 easily building fast, scalable network applications • Google V8 Javascript Engine (Same technology in Google Chrome) • NPM Package Manager (Come by default great as it should be: 48,362 modules) • Realtime, Command line, Many tools Saturday, November 23, 13
  11. 11. When do we need a web? • Download web server and install • Install PHP and maybe database • Configuration…. • And now we can put our code on it! Saturday, November 23, 13
  12. 12. See Node.js way! (create a web server, just in 6 lines of code) 1 Download and click install apt-get install nodejs 2 var http = require('http'); http.createServer(function (req, res) { res.writeHead(200); res.end("Hello World!n"); }).listen(3000); console.log('Server running at http://localhost:3000/'); Saturday, November 23, 13
  13. 13. It just works! Web server and ready for a huge traffic :) even 10,000/reqs var http = require('http'); http.createServer(function (req, res) { res.writeHead(200); res.end("Hello World!n"); }).listen(3000); console.log('Server running at http://localhost:3000/'); Saturday, November 23, 13
  14. 14. Blocking I/O var a = db.query(“SELECT * FROM users”); console.log(‘Result a:’, a); var b = db.query(“SELECT * FROM documents”); console.log(‘Result B:’, b); Saturday, November 23, 13
  15. 15. Blocking I/O var a = db.query(“SELECT * FROM users”); console.log(‘Result a:’, a); wait var b = db.query(“SELECT * FROM documents”); console.log(‘Result B:’, b); Waste cpu cycles from waiting… other part of code, they need to wait too! Saturday, November 23, 13 wait
  16. 16. Blocking I/O var a = db.query(“SELECT * FROM users”); console.log(‘Result a:’, a); wait var b = db.query(“SELECT * FROM documents”); console.log(‘Result B:’, b); sum ( a + b) Saturday, November 23, 13 wait
  17. 17. Non Blocking I/O var a = db.query(“SELECT * FROM users”, function(result){ console.log(‘Result a:’, a); } ); var b = db.query(“SELECT * FROM documents”, function(result){ console.log(‘Result b:’, ab); } ); Saturday, November 23, 13
  18. 18. Non Blocking I/O var a = db.query(“SELECT * FROM users”, function(result){ console.log(‘Result a:’, a); } ); run parallel var b = db.query(“SELECT * FROM documents”, function(result){ console.log(‘Result b:’, ab); } ); max ( a, b ) Saturday, November 23, 13 run parallel
  19. 19. Benchmark nginx (non blocking i/o) Saturday, November 23, 13 apache (blocking i/o)
  20. 20. Suitable Applications • Single page app • Full web app • Realtime app chat, notification, games • Crawler, Bot • Streaming • File uploading Saturday, November 23, 13
  21. 21. Who using now? and thousand thousand more… including me... Molome .... Saturday, November 23, 13
  22. 22. You should try! • It’s not hard to start if you familiar with Javascript • If you looking for another language • It’ll change the way you do a web • And it’s FUN!! Saturday, November 23, 13
  23. 23. Start now! http://github.com/hunt/seventies template for node.js web application by me! https://github.com/jlleblanc/nodejs-joomla module for Joomla Saturday, November 23, 13
  24. 24. Q&A Free to ask! Saturday, November 23, 13

×