Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Node.js: Server of Many Uses

Node.js: Server of Many Uses

An incomplete tour of just a few of the awesome unconventional (for a web stack) things people are doing with node.js. Presented at the Colorado Springs Open Source Users Group Feb 23, 2012

7071119714e1a32441aca0c336657d3e?s=128

Mike Brevoort

March 06, 2012
Tweet

Transcript

  1. node.js server of many uses Mike Brevoort Colorado Springs Open

    Source Users Group 23 February 2012 1
  2. Mike Brevoort @mbrevoort work at... (though opinions expressed in this

    presentation are my own and not meant to represent Pearson) 2
  3. agenda very brief intro to node.js a tour of some

    “unconventional” uses of node.js * though I don’t particularly like the work conventional 3
  4. node.js An Evented I/O network server for Javascript created by

    Ryan Dahl sponsored by 4
  5. “Most languages were designed to solve computational problems, but Node.js

    is different. Node.js was designed from the ground up to efficiently handle the communication that is at the heart of modern web applications.” http://www.joyentcloud.com/products/smart-appliances/ node-js-smartmachine/ 5
  6. generating load 6

  7. “Mozilla uses a single node thread to simulate 180K users!

    I have commercial testing gear that can't do that! #nodesummit” Chris Johnson @mast3rof0 - 1/24/2012 7
  8. https://gist.github.com/1861747 8

  9. 9

  10. interprocess RPC 10

  11. DNode symmetric remote function calling between processes to/from the browser

    via socket.io JSON protocol dnode ports in ruby, java, php, perl https://github.com/substack/dnode async rpc through sockets/JSON 11
  12. server client 12

  13. headless testing 13

  14. zombie.js fast headless simulated browser testing emulation 14

  15. zombie.js fast headless simulated browser testing Cookies and Web Storage

    XMLHttpRequest in all its glory setTimeout/ setInterval pushState, popstate and hashchange events alert, confirm and prompt HTML5 parsing and dealing with tag soups DOM Level 3 implementation HTML5 form fields (search, url, etc) CSS3 Selectors with some extensions 15
  16. headless WebKit with JavaScript API Fast and native NOT node.js

    But node is commonly used as an orchestrator 16
  17. phantomjs-node “...implements a nauseously clever bridge between Phantom and Node”

    17
  18. screenshotting 18

  19. curl http://localhost:3000/cnn.com > cnn.png https://github.com/visionmedia/screenshot-app screenshot-app web screenshotting 19

  20. webcrawling 20

  21. 21

  22. 22

  23. browser APIs or fallbacks 23

  24. node-canvas https://github.com/LearnBoost/node-canvas HTML5 server-side canvas API fallback run canvas API

    calls in node, send an image back to the client great for some mobile use cases legacy browser fallback 24
  25. Deployments 25

  26. https://github.com/substack/propagit multi-server git deployment over http Propagit Hub drone drone

    drone drone git push http://hubhost:6001/ somerepo master repos/somerepo.git repos/somerepo.git repos/somerepo.git repos/somerepo.git 26
  27. Propagit https://github.com/substack/propagit multi-server git deployment over http Hub drone drone

    drone drone propagit deploy --hub=hubhost:6000 --secret=beepboop \ somerepo ed56c6e85731d412fe22cf437cb63130afc34b07 deploy/ somerepo.ed56c... deploy/ somerepo.ed56c... deploy/ somerepo.ed56c... deploy/ somerepo.ed56c... 27
  28. Propagit https://github.com/substack/propagit multi-server git deployment over http Hub drone drone

    drone drone propagit spawn --hub=hubhost:6000 --secret=beepboop \ somerepo ed56c6e85731d412fe22cf437cb63130afc34b07 \ -- node server.js 8085 deploy/ somerepo.ed56c... deploy/ somerepo.ed56c... deploy/ somerepo.ed56c... deploy/ somerepo.ed56c... 28
  29. load balancing 29

  30. Bouncy programmatic http load balancer and router https://github.com/substack/bouncy 30

  31. Bouncy programmatic http load balancer and router https://github.com/substack/bouncy 31

  32. network tracing 32

  33. node_pcap decode, print and analyze packets node makes it very

    nice since each packet is emitted as a Buffer by the EventEmitter libpcap bindings https://github.com/mranney/node_pcap 33
  34. shell scripting 34

  35. shell scripting fs core library - abstract OS or shell

    implementation details can leverage the node module ecosystem great if you need to do I/O beyond filesystem npm client 35
  36. fs.watch(filename, [options], listener) 36

  37. https://github.com/polotek/procstreams pipe-able and composable shell scripting in node Procstreams 37

  38. Browser fallbacks Deployment Load balancing Network tracing Shell scripting Load

    generation IPC Testing Screenshotting Webcrawling tip of the iceberg 38
  39. @mbrevoort Mike Brevoort Thanks! Questions? 39