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, toy or power tool?                            Jax CodeCamp, Oct 2012                                 Ovidiu Dimul...
Agenda                      •   What problem?                      •   How’s Node.js helping?                      •   Use...
About @odimulescu         • Working on the Web since 1997         • Into startup and engineering cultures         • Speake...
Node.js - What’s the problem?        Fast CPUs Spinning wheels        How do we saturate the CPU doing useful work?Saturda...
Node.js - How’s it helping?                          • Uses event-driven, non-blocking IO                          • Enfor...
Multi-Threaded Servers       *Credit: blog.cloudfoundry.comSaturday, October 6, 12
Node.js - Single Thread, Event-ed       *Credit: blog.cloudfoundry.comSaturday, October 6, 12
Node.js - Concurrency                          Node.js Event Loop              Rq1                              Rq1       ...
Node.js - Concurrency                          Thread                          Node.js                                    ...
Node.js - Been there, done that         Event Machines              •           - Twisted              •           - Event...
Node.js - But ...                          They mix async with sync and the mentality is                          towards ...
Node.js - Use Cases         • Proxy between different data layers         • Soft real-time apps         • Crawlers        ...
Node.js - Not best fit         • Culture mismatch         • Uses Javascript         • Requests are CPU intensive         • ...
Node.js - Industry SupportSaturday, October 6, 12
Node.js - Industry UsageSaturday, October 6, 12
Node.js - Installation                          1. Go to nodejs.org                          2. Download and run installer...
Node.js - Installation         1. Go to nodejs.org         2. Download and run installer         What’s included?         ...
Node.js - Server Installation         1. Regular Installation         2. Make it a service              Windows - NSSM, sr...
Node.js -                  Considerations         Lowest privileges              Unix: drop to non-root via setuid / setgu...
Node.js - Hello World         CLI Version - helloworld.js              console.log(“Hello world”);              $ node hel...
Node.js - Hello World         Web - Router VersionSaturday, October 6, 12
Node.js - I will call you backSaturday, October 6, 12
Node.js - When, thenSaturday, October 6, 12
Node.js - Flow libraries         Serial independent              Runs a series of functions one after the previous functio...
Node.js - Modules         Module - mymodule.js         Client mymodule_client.jsSaturday, October 6, 12
Node.js - Modules        package.json        require(‘mylib’) - Lookup order               1. package.json -> ./lib/mylib....
Node.js - Logging              •     console              •     log4js              •     Winston              •     GELF ...
Node.js - Debugging         $ npm install node-inspector         $ node --debug-brk myapp.js         $ node --debug myapp....
Node.js - InspectorSaturday, October 6, 12
Node.js - DebuggingSaturday, October 6, 12
Node.js - DB / ORM         Database Drivers              MS SQL, MongoDB, PostgreSQL, MySQL, Oracle, SQLite,              ...
Node.js - Web frameworks              •      Derby              •      Express              •      Flatiron              •...
Node.js - Testing frameworks              •      assert - built in              •      API Easy              •      Cucumb...
Node.js - Scaling outSaturday, October 6, 12
Node.js - Scaling out     *Credit: blog.evantahler.comSaturday, October 6, 12
Node.js - Wrapping up         • Reuse existing JavaScript skill and code         • Low resource usage         • Performant...
Q &ASaturday, October 6, 12
Upcoming SlideShare
Loading in …5
×

Node.js, toy or power tool?

6,213 views

Published on

Published in: Technology
  • Be the first to comment

Node.js, toy or power tool?

  1. 1. Node.js, toy or power tool? Jax CodeCamp, Oct 2012 Ovidiu DimulescuSaturday, October 6, 12
  2. 2. Agenda • What problem? • How’s Node.js helping? • Use cases • Industry support • Coding in Node.js • Ecosystem • Q &ASaturday, October 6, 12
  3. 3. About @odimulescu • Working on the Web since 1997 • Into startup and engineering cultures • Speaker at user groups • Organizer for JaxMUG.com • Co-Organizer for Jax Big Data meetupSaturday, October 6, 12
  4. 4. Node.js - What’s the problem? Fast CPUs Spinning wheels How do we saturate the CPU doing useful work?Saturday, October 6, 12
  5. 5. Node.js - How’s it helping? • Uses event-driven, non-blocking IO • Enforces async throughout*Saturday, October 6, 12
  6. 6. Multi-Threaded Servers *Credit: blog.cloudfoundry.comSaturday, October 6, 12
  7. 7. Node.js - Single Thread, Event-ed *Credit: blog.cloudfoundry.comSaturday, October 6, 12
  8. 8. Node.js - Concurrency Node.js Event Loop Rq1 Rq1 Rq2 Rq2 Green - Request Executing Red - IO waitSaturday, October 6, 12
  9. 9. Node.js - Concurrency Thread Node.js Higher Concurrency Same LatencySaturday, October 6, 12
  10. 10. Node.js - Been there, done that Event Machines • - Twisted • - EventMachine • - Mina, Netty, Atmosphere, vertx.io • - POE Others • Erlang • Scala / AkkaSaturday, October 6, 12
  11. 11. Node.js - But ... They mix async with sync and the mentality is towards sync in libraries, drivers etc.Saturday, October 6, 12
  12. 12. Node.js - Use Cases • Proxy between different data layers • Soft real-time apps • Crawlers • CLI tools • Quick prototyping • Lower HW and Operational cost*Saturday, October 6, 12
  13. 13. Node.js - Not best fit • Culture mismatch • Uses Javascript • Requests are CPU intensive • Apps relies on specific libraries / functionality • Transactional systemsSaturday, October 6, 12
  14. 14. Node.js - Industry SupportSaturday, October 6, 12
  15. 15. Node.js - Industry UsageSaturday, October 6, 12
  16. 16. Node.js - Installation 1. Go to nodejs.org 2. Download and run installerSaturday, October 6, 12
  17. 17. Node.js - Installation 1. Go to nodejs.org 2. Download and run installer What’s included? node - binary npm - cli package manager built-in support for http, net, dnsSaturday, October 6, 12
  18. 18. Node.js - Server Installation 1. Regular Installation 2. Make it a service Windows - NSSM, srvany, etc. Unix - Distro dependent 3. Front-end WS Integration IIS 7+ Integration - iisnode Apache - mod_proxy or mod_rewrite Nginx - rewrite or proxy HAProxy, stunnelSaturday, October 6, 12
  19. 19. Node.js - Considerations Lowest privileges Unix: drop to non-root via setuid / setguid Front with a secure Proxy Enable safeguards “use strict”Saturday, October 6, 12
  20. 20. Node.js - Hello World CLI Version - helloworld.js console.log(“Hello world”); $ node helloworld.js Hello World Web VersionSaturday, October 6, 12
  21. 21. Node.js - Hello World Web - Router VersionSaturday, October 6, 12
  22. 22. Node.js - I will call you backSaturday, October 6, 12
  23. 23. Node.js - When, thenSaturday, October 6, 12
  24. 24. Node.js - Flow libraries Serial independent Runs a series of functions one after the previous function completed Serial dependent Runs a series of functions passing previous results into next function Parallel fashion Runs a series of function in parallel Queue Runs a series of function in parallel up to desired concurrency Library Choices Async, Groupie, Step, Q, etc.Saturday, October 6, 12
  25. 25. Node.js - Modules Module - mymodule.js Client mymodule_client.jsSaturday, October 6, 12
  26. 26. Node.js - Modules package.json require(‘mylib’) - Lookup order 1. package.json -> ./lib/mylib.js 2. index.js 3. index.nodeSaturday, October 6, 12
  27. 27. Node.js - Logging • console • log4js • Winston • GELF - Graylog Extended Log Format • Windows Event Log ...Saturday, October 6, 12
  28. 28. Node.js - Debugging $ npm install node-inspector $ node --debug-brk myapp.js $ node --debug myapp.js debugger listening on port 5858 $ node-inspector visit http://0.0.0.0:8080/debug?port=5858 to start debugging Debuggers WebKit based: Chrome Eclipse V8 Debugger Plugin, JetBrains WebStorm Other Tools v8-profiler, node-profiler nodetime.comSaturday, October 6, 12
  29. 29. Node.js - InspectorSaturday, October 6, 12
  30. 30. Node.js - DebuggingSaturday, October 6, 12
  31. 31. Node.js - DB / ORM Database Drivers MS SQL, MongoDB, PostgreSQL, MySQL, Oracle, SQLite, Redis, CouchDB, Hive, Riak, Cassandra ORMs sequelize, persist, LazyBoy, Model, jugglingdb, node-orm Transactions, Connection Pooling node-mysql-queuesSaturday, October 6, 12
  32. 32. Node.js - Web frameworks • Derby • Express • Flatiron • Meteor • Mojito • Tower ... Browserify - Node to Browser conversionSaturday, October 6, 12
  33. 33. Node.js - Testing frameworks • assert - built in • API Easy • Cucumber • httpmock, nock, mockery • NodeUnit • Soda ...Saturday, October 6, 12
  34. 34. Node.js - Scaling outSaturday, October 6, 12
  35. 35. Node.js - Scaling out *Credit: blog.evantahler.comSaturday, October 6, 12
  36. 36. Node.js - Wrapping up • Reuse existing JavaScript skill and code • Low resource usage • Performant VM (Google’s V8) • Active Community, Lots of resources • Package Manager • Enforces Async across • Quick Prototyping • Growing Industry supportSaturday, October 6, 12
  37. 37. Q &ASaturday, October 6, 12

×