Introduction to Node.js

2,420 views

Published on

Introduction to Node.js

Published in: Software, Technology

Introduction to Node.js

  1. 1. An introduction ...
  2. 2. Agenda
  3. 3. Agenda ● What is Node.js
  4. 4. Agenda ● What is Node.js ● How Node.js works
  5. 5. Agenda ● What is Node.js ● How Node.js works ● Some Node.js examples
  6. 6. Agenda ● What is Node.js ● How Node.js works ● Some Node.js examples ● How to learn Node.js
  7. 7. Agenda ● What is Node.js ● How Node.js works ● Some Node.js examples ● How to learn Node.js ● What Node.js is good at
  8. 8. What is Node.js
  9. 9. What is Node.js Server-side JavaScript
  10. 10. What is Node.js Server-side JavaScript Node.js is a platform built on Chrome's JavaScript runtime.
  11. 11. What is Node.js Server-side JavaScript Node.js is a platform built on Chrome's JavaScript runtime. Node.js uses an event-driven, non-blocking model to execute I/O intensive applications.
  12. 12. Node.js and I/O Source : https://www.altamiracorp.com/blog/employee-posts/nodejs-basics-explained 3
  13. 13. Node.js and I/O Source : https://www.altamiracorp.com/blog/employee-posts/nodejs-basics-explained 3 5
  14. 14. Node.js and I/O Source : https://www.altamiracorp.com/blog/employee-posts/nodejs-basics-explained 3 5 250
  15. 15. Node.js and I/O Source : https://www.altamiracorp.com/blog/employee-posts/nodejs-basics-explained 3 5 250 41,000,000
  16. 16. Node.js and I/O Source : https://www.altamiracorp.com/blog/employee-posts/nodejs-basics-explained 3 5 250 41,000,000 240,000,000
  17. 17. Node.js Event Loop Open File Connect to Socket Write to DB Event Queue
  18. 18. Node.js Event Loop Open File Connect to Socket Write to DB Event Queue Event Loop
  19. 19. Node.js Event Loop Open File Connect to Socket Write to DB Event Queue File System Network Process Other Event Loop
  20. 20. Node.js Event Loop Open File Connect to Socket Write to DB Event Queue File System Network Process Other Event Loop Callbacks (e.g. File Opened)
  21. 21. Node.js Example 1 var fs = require('fs'); 2 3 fs.readFile(filename, function(err, data) { 4 var lines = data.toString().split('n'); 5 console.log(lines.length); 6 });
  22. 22. Node.js Stack Node Standard Library
  23. 23. Node.js Stack Node Standard Library Node C++ Bindings (http, socket, filesystem)
  24. 24. Node.js Stack Node Standard Library V8 threadpool (libeio) event loop (libev) crypto (Open SSL) dns (c-ares) Node C++ Bindings (http, socket, filesystem)
  25. 25. Node.js Stack Node Standard Library Node C++ Bindings (http, socket, filesystem) V8 threadpool (libeio) event loop (libev) crypto (Open SSL) dns (c-ares)
  26. 26. Getting Started ● http://nodejs.org/ ● Download tar.gz ● Extract to any directory ● $ ./configure ● $ make install
  27. 27. Demo ● The Node.js repl ● npm and a simple webserver
  28. 28. Great learning resources
  29. 29. Great learning resources nodeschool.io
  30. 30. Great learning resources nodeschool.io
  31. 31. Great learning resources nodeschool.io
  32. 32. Great learning resources nodeschool.io
  33. 33. Great learning resources nodeschool.io
  34. 34. Great learning resources nodeschool.io
  35. 35. Great learning resources nodeschool.io
  36. 36. Great learning resources nodeschool.io
  37. 37. Great learning resources nodeschool.io
  38. 38. Great learning resources nodeschool.io
  39. 39. Great learning resources codewars.com
  40. 40. Great learning resources
  41. 41. Great learning resources
  42. 42. Great learning resources nodejsdublin.com
  43. 43. Great learning resources nodeup.com
  44. 44. What is Node.js good at?
  45. 45. Node.js is good at ... Node.js Webserver DB Client #1 Client #2 Client #3 Chat Server
  46. 46. Node.js is good at ... Node.js Webserver DB Client #1 Client #2 Client #3 Chat Server
  47. 47. Node.js is good at ... Node.js Webserver DB Client #1 Client #2 Client #3 Chat Server
  48. 48. Node.js is good at ... Node.js Server File System Producer #1 Producer #2 Producer #3 Message Queuing System Consumer #1 Consumer #2 Consumer #3
  49. 49. Node.js is good at ... Node.js Server File System Producer #1 Producer #2 Producer #3 Message Queuing System Consumer #1 Consumer #2 Consumer #3
  50. 50. Node.js is good at ... Node.js Server File System Producer #1 Producer #2 Producer #3 Message Queuing System Consumer #1 Consumer #2 Consumer #3
  51. 51. Node.js is good at ... Microservices
  52. 52. Microservices ● Small unit of functionality
  53. 53. Microservices ● Small unit of functionality ● About 100 lines long (can fit in your head)
  54. 54. Microservices ● Small unit of functionality ● About 100 lines long (can fit in your head) ● Independently deployed
  55. 55. Microservices ● Small unit of functionality ● About 100 lines long (can fit in your head) ● Independently deployed ● Loosely Coupled
  56. 56. Microservices ● Small unit of functionality ● About 100 lines long (can fit in your head) ● Independently deployed ● Loosely Coupled ● Codeable in a week
  57. 57. Microservices ● Small unit of functionality ● About 100 lines long (can fit in your head) ● Independently deployed ● Loosely Coupled ● Codeable in a week ● Owned by one developer
  58. 58. Microservice Examples ● Store json object in MongoDB
  59. 59. Microservice Examples ● Store json object in MongoDB ● Calculate if it is time to scale app
  60. 60. Microservice Examples ● Store json object in MongoDB ● Calculate if it is time to scale app ● Receive user input and forward request to another part of your app
  61. 61. Node.js is good at ... Microservices Web Browser HDFS HBase MySQL AuthorisationAuthentication Web Layer Component Query HBaseExpire Old Data Roll up Data
  62. 62. Node.js is good at ... Microservices Web Browser Authentication Authorisation Web Layer Component Query HBaseExpire Old Data Roll up Data Node.js Proxy
  63. 63. Node.js is good at ... Microservices Web Browser Authentication Authorisation Web Layer Component Query HBaseExpire Old Data Roll up Data Node.js Proxy
  64. 64. Worth watching You Only Need 100 Lines of JavaScript Pragmatic Javascript
  65. 65. Notable Quotables “We, among many others, find Node.js to be an order of magnitude faster than other tools for developing services.” http://www.feedhenry.com/transforming-enterprise-node-js-feedhenry/
  66. 66. Notable Quotables “In real web production, in real large scale systems, in real internet companies, node is outperforming the java stack in every case.” http://www.nearform.com/nodecrunch/release-the-kracken-how-paypal- is-being-revolutionized-by-node-js-and-lean-ux
  67. 67. More tech talks, please! ● Java 8 language features and the runtime ● Javascript technologies and language features ● Coder dojo ● Docker and LXC ● Build tools like Gradle and Grunt ● Working in real-life with Scala and Java ● Linux command line, environment tips and VI. ● The Linux OS in general (Kernal and system directories) ● Architecture “We want Volunteers, not Conscripts!”

×