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.

Getting Started with MongoDB and Node.js

83,295 views

Published on

Slides from my talk at Mongo Seattle 2010.

Published in: Technology

Getting Started with MongoDB and Node.js

  1. 1. Getting Started With Node.js and mongoDB Grant Goodale (@ggoodale) 7/26/2010
  2. 2. What is ? “Evented I/O for V8 Javascript” – http://nodejs.org Application engine for “scalable network applications” Really freaking fast: One process, zero* threads (Almost) no blocking * actually, there is a thread pool. We’ll get to that.
  3. 3. What is ? High concurrency with low overhead No thread swapping or context switching Applications must be designed from the ground up to not block on I/O, CPU-intensive work, etc.
  4. 4. What Node.js Isn’t A full-stack web framework (a la Ruby on Rails) But! you can get there: ExpressJS: (http://expressjs.com/) (Web framework with MongoDB support built in - similar to Sinatra) http://github.com/senchalabs/connect (Rack-like middleware for Node and Express) haml.js: http://github.com/visionmedia/haml.js (Pure js implementation of HAML)
  5. 5. What Node.js Isn’t (cont.) Great at sending large static files concurrently. (use nginx.) Buffer implementation in recent versions improves this dramatically: http://nodejs.org/jsconf2010.pdf Completely non-blocking. CPU-intensive stuff will still block you (do it in a worker process). Some system calls (executed in a thread pool)
  6. 6. & http://www.flickr.com/photos/tonyjcase/2803950283/
  7. 7. & Great together! Both: speak Javascript understand JSON documents are freaking fast. So, what should you build?
  8. 8. & You can build: Standard n-tier web applications Great way to learn mongoDB and Node Go build a blog engine! (Everyone does.) Lots of libraries to help you get started: ExpressJS, Connect, etc.
  9. 9. & You should build: Applications requiring high throughput and concurrency Applications with real-time needs Applications with long-polling connections Real-time multiuser chat Web or log analytics (e.g. Hummingbird)
  10. 10. Getting Started Grab the following: mongoDB: http://www.mongodb.org/downloads Node.js: http://nodejs.org/#download npm, a package manager for Node: curl http://npmjs.org/install.sh | sh
  11. 11. Getting Started Use npm to install a mongoDB driver for Node: npm install mongodb Tons of other fun stuff as well - full package list at http://npm.mape.me/
  12. 12. Evented I/O: a Primer Before:
  13. 13. Evented I/O: a Primer After:
  14. 14. Evented I/O: a Primer After:
  15. 15. Evented I/O: a Primer After:
  16. 16. A simple example: Syslog
  17. 17. Mongoose http://www.learnboost.com/mongoose/ Cleans up a bit of the nested callback “fun”
  18. 18. Mongoose http://www.learnboost.com/mongoose/ Cleans up a bit of the nested callback “fun”
  19. 19. Mongoose Adds ORM capabilities (but doesn’t mandate them)
  20. 20. Other Fun Stuff: http://wiki.github.com/ry/node/modules (Need extensions? We got 'em.) Routers, file servers, frameworks, crypto... http://socket.io/: Cross-platform WebSockets Supports HTML5 websockets Falls back to Flash / AJAX in less capable browsers
  21. 21. Questions? twitter: ggoodale email: grant@moreblinktag.com

×