NodeSummit - MEAN Stack

3,562 views
3,250 views

Published on

Valeri Karpov's talk about the MEAN stack at NodeSummit on 12/3/13

Published in: Technology
1 Comment
8 Likes
Statistics
Notes
No Downloads
Views
Total views
3,562
On SlideShare
0
From Embeds
0
Number of Embeds
126
Actions
Shares
0
Downloads
79
Comments
1
Likes
8
Embeds 0
No embeds

No notes for slide

NodeSummit - MEAN Stack

  1. 1. Intro to the MEAN Stack Using NodeJS to drive superheroic web apps Valeri Karpov Kernel Tools Engineer, MongoDB thecodebarbarian.com github.com/vkarpov15 @code_barbarian
  2. 2. Who is this guy? CTO 2008
  3. 3. What does MEAN mean? MongoDB - document database ExpressJS - web framework for NodeJS AngularJS - client MVVM, server ⇔ UX NodeJS - event-driven IO in Javascript
  4. 4. What is this talk about? - Building a new web app: its easy… - … except when it isn’t Expectation Reality
  5. 5. The Problem Categories Your problems look something like this: Prototype. Build a usable product fast Adapt. Iterate on feedback Test. Automate testing using CI Scale. Utilize server resources efficiently
  6. 6. Prototype “Done is better than perfect.” - Facebook developer mantra
  7. 7. Prototype - Goal: Get usable product in users’ hands fast - Success story: Ascot Project
  8. 8. Prototype - Surface: one language makes life easier - Surface: package management - Deeper: tight binding from database to client
  9. 9. Start with a UI Interactive client-side templating Client-side: JSON bound to state of view
  10. 10. Server View of Data Interactive client-side templating Server receives JSON data as-is
  11. 11. Database View of Data Interactive client-side templating MongoDB stores JSON data as-is
  12. 12. Why is this useful? - Lower barrier to entry for new devs - Declarative UX - Easier debugging - Code reuse
  13. 13. Adapt “There's a plaque on our wall that says we've sold over 65 million albums, and I don't feel I've accomplished anything. I feel like I'm just getting started.” - Eddie Van Halen
  14. 14. Adapt - Application always starts out simple, but... - REST APIs. Socket APIs. SMTP. - How will you integrate with new tech?
  15. 15. The NodeJS Advantage - Threads and locks are difficult - Cron jobs are difficult - Your server needs to be concurrent - NodeJS provides easy, testable concurrency
  16. 16. Best Case Scenario - Bitcoin arbitrage from apartment - 1 hour from nothing to live trading - 15 minutes to add a new exchange
  17. 17. Test “Beware of bugs in the above code; I have only proved it correct, not tried it.” - Donald Knuth, former Stanford CS Professor
  18. 18. The Challenge How do you prove your code works? Success story: Bookalokal
  19. 19. The Evolution of Testing - Manual testing? - Unit tests? - E2E tests? - Test runners? - Continuous Integration.
  20. 20. MEAN Stack Advantage - Javascript makes unit testing very easy - Trivial dependency injection: - AngularJS has built-in DI - Lots of NodeJS DI, recommend https://npmjs.org/package/omni-di
  21. 21. MEAN Stack Advantage - E2E tests: angular-scenario
  22. 22. Karma test-runner - http://karma-runner.github.io - Launch browsers, run tests on file save - Compatibility: angular-scenario, nodeunit, jasmine
  23. 23. Karma and CI - Jenkins: http://bit.ly/1fVqoC9 - Circle CI: http://bit.ly/1dhuR4A - Travis CI: http://bit.ly/I3ojbF - Semaphore: http://bit.ly/IgiWFz
  24. 24. Scale “Go Big or Go Extinct” - Tagline to the 2013 film Pacific Rim
  25. 25. A Word of Caution... Scalability is (mostly) a Maserati Problem http://bit.ly/17gOvUO (Moderately NSFW)
  26. 26. Scale… to what? - Difficult to judge exact number, say O(1000) - Single machine - 20% of mistakes 80% of new apps make - Horror story: SCNVGR, 10/18/08
  27. 27. What are the key points? - Don’t be Schlemiel the Painter
  28. 28. Bandwidth is scarce - Is the browser caching static assets? - Is your CSS and JS minified? - Grunt everybody’s favorite minifier - Bonus minify css/js on server start using uglify-js.
  29. 29. Hard drive is slow - Especially true on EC2 - not an actual HD! - Is your database reading from HD? - MongoDB: In-memory “caching” built in! :)
  30. 30. Don’t choke the CPU - Is your server single-threaded? - NodeJS: You get this for free! :)
  31. 31. A Common Criticism Will MEAN be obsolete in 5 years? I hope so. “To know ten thousand things, know one thing well.” - The Book of Five Rings by Miyamoto Musashi
  32. 32. Thanks for Listening! Comments, questions, haikus? Read more at: thecodebarbarian.com github.com/vkarpov15 @code_barbarian

×