Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Nodejs a-practical-introduction-oredev

5.667 Aufrufe

Veröffentlicht am

Talk given at Øredev on Nov 9, 2011. Includes a brief history, current status and practical applications of node.js.

Veröffentlicht in: Technologie
  • Dating direct: ♥♥♥ http://bit.ly/2Qu6Caa ♥♥♥
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • Sex in your area is here: ❤❤❤ http://bit.ly/2Qu6Caa ❤❤❤
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier

Nodejs a-practical-introduction-oredev

  1. 1. A practical introductionFelix Geisendörfer Øredev 09.11.2011 (v1)
  2. 2. @felixgeTwitter / GitHub / IRC Felix Geisendörfer (Berlin, Germany)
  3. 3. Audience?
  4. 4. JavaScript?
  5. 5. Node.js?
  6. 6. History
  7. 7. Feb 16, 2009Ryan Dahl starts the node project (first commit)
  8. 8. ~June, 2009Discovered node.js (v0.0.6)
  9. 9. transloadit.com
  10. 10. Core Contributor & Module Authornode-mysql node-formidable + 30 other modules
  11. 11. Sep 29, 2009Isaac Schlueter starts the npm package manager (first commit)
  12. 12. Nov 7, 2009Ryan’s talk at JSConf.EU gets people excited about node
  13. 13. Today
  14. 14. #22nd most watched repository on GitHub
  15. 15. 230 Contributors
  16. 16. 0.6.0 was released 4 days ago (Nov 5)
  17. 17. Companies using node• GitHub (for Downloads)• Palm/HP (in WebOS)• Yahoo! Mail• Dow Jones & Company (for WJS social site)• LinkedIn (Mobile Web App)• Rackspace (Cloudkick monitoring)• Voxxer (Push to Talk mobile app)
  18. 18. Installing$ git clone git://github.com/joyent/node.git$ cd node$ git checkout v0.6.0$ ./configure$ sudo make install (windows users: download node.exe)
  19. 19. Hello Worldhello.jsconsole.log(Hello World);$ node hello.jsHello World
  20. 20. Hello World (REPL) $ node > console.log(Hello World) Hello World
  21. 21. Http Serverhttp_server.jsvar http = require(http);var server = http.createServer(function(req, res) { res.end(Hi, how are you?);});server.listen(8080);$ node http_server.js $ curl localhost:8080 Hi, how are you?
  22. 22. “Come on, server side JS has been around since 1996”
  23. 23. What is so special about node?
  24. 24. Speed
  25. 25. Speed• Node can do ~6000 http requests / sec per CPU core (hello world, 1kb response,)• It is no problem to handle thousands of concurrent connections which are moderately active
  26. 26. V8 JavaScript Engine
  27. 27. V8 JavaScript Engine• Developed by Google in Aarhus, Denmark for Google Chrome• Translates JavaScript in Assembly Code• Crankshaft JIT (enabled in 0.6.0 by default)
  28. 28. V8 JavaScript Engine• You can expect to be within ~10x of C performance usually• Certain code can run within 2-3x of C• Getting faster all the time
  29. 29. Non-Blocking I/O
  30. 30. Blocking I/Oread_file_sync.jsvar fs = require(fs);var one = fs.readFileSync(one.txt, utf-8);console.log(Read file one);var two = fs.readFileSync(two.txt, utf-8);console.log(Read file two); $ node read_file_sync.js Read file one Read file two
  31. 31. Non-Blocking I/Oread_file_async.jsvar fs = require(fs);fs.readFile(one.txt, utf-8, function(err, data) { console.log(Read file one);});fs.readFile(two.txt, utf-8, function(err, data) { console.log(Read file two);}); $ node read_file_async.js Read file two Read file one
  32. 32. Blocking I/ORead one.txt (20ms) Read two.txt (10ms) Total duration (30ms)
  33. 33. Non-Blocking I/ORead one.txt (20ms)Read two.txt (10ms) Total duration (20ms)
  34. 34. Non-Blocking I/O• Close to ideal for high concurrency / high throughput, single execution stack• Forces you to write more efficient code by parallelizing your I/O• Feels pretty much like AJAX in the browser
  35. 35. WebSockets (Push)
  36. 36. WebSockets• Persistent connection between browser/server• Very hard / awkward to do on traditional stacks• Hard to scale on traditional stacks
  37. 37. Socket.IO (community module) • WebSocket • Adobe® Flash® Socket • AJAX long polling • AJAX multipart streaming • Forever Iframe • JSONP PollingChooses most capable transport at runtime!
  38. 38. Streams
  39. 39. “Streams are to time as arrays are to space.” -- Jed Schmidt @ JSConf.eu 2010
  40. 40. Streams in node.js• Readable• Writable• Both
  41. 41. Streamsvar http = require(http);var server = http.createServer(function(req, res) { req.on(data, console.log);});server.listen(8080);$ node stream.js &$ curl -F file=@stream.js localhost:8080------------------------------41e92562223eContent-Disposition: form-data; name="file"; filenameContent-Type: application/octet-streamvar http = require(http);var server = http.createServer(function(req, res) {
  42. 42. Streamsvar http = require(http);var spawn = require(child_process).spawn;http.createServer(function(req, res) { var params = req.url.split(/); var args = [params[1], -resize, params[2], -]; var convert = spawn(convert, args); convert.stdout.pipe(res);}).listen(8080);
  43. 43. On Githubfelixge/node-convert-example
  44. 44. NPM package manager
  45. 45. NPM• Puts dependencies in the right place, then gets out of your way• No modification of a global load path (require.paths is gone in 0.6.0)• 4700+ Modules in npm, > 10 new modules / day
  46. 46. So what is node good for?
  47. 47. Use cases• WebSockets/Push applications• Proxying data streams• Backend for single page apps
  48. 48. Use cases• Spawning other programs (processes) to do work / IPC• Parallelizing I/O
  49. 49. So what is node not good for?
  50. 50. Anti-Use cases• Actual Realtime Systems• Number crunching / huge in-memory datasets• (CRUD apps)
  51. 51. Join the Community• Mailing list (nodejs, nodejs-dev)• IRC (#node.js) - 700+ User online
  52. 52. Thank you!
  53. 53. Questions? @felixge
  54. 54. Thank you!
  55. 55. Bonus Slide
  56. 56. What’s next?• Domains• Improved Stream API

×