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

Big app design for Node.js

Big app design for Node.js

Designing the code of a large application in production and scaling up to thousands of users while doing it all in Node.js is a challenge that no developer should face alone. I will discuss how we have developed a highly decoupled, plugin-based architecture and a decentralized infrastructure for Cloud9 IDE, along with the technologies we've developed and the difficulties we faced in order to build the largest Node.js application that exists in production.

Sergi Mansilla

November 10, 2012
Tweet

More Decks by Sergi Mansilla

Other Decks in Technology

Transcript

  1. duplicated modules maps to folder names Relies on FS require

    hard to configure module Saturday, November 10, 12
  2. Dependency error handling coding time compile time run time KA-BOOM!

    - Server crash - Unhappy customers - Developer gets fired Saturday, November 10, 12
  3. How to fix it? Static dependency list Named services Easy

    configuration Resolve at startup No FS required Pass an object Saturday, November 10, 12
  4. Everything is a plugin Plugins can consume plugins An application

    is just a set of plugins Architect Saturday, November 10, 12
  5. Dependency error handling Architect coding time compile time run time

    - Happy customers - Developer keeps job - Fails before release Saturday, November 10, 12
  6. Next Extract the code Wrap in Architect plugin code Make

    two plugins Saturday, November 10, 12
  7. Architect plugin code Module.exports Options - we’ll talk about it

    later Imports - everything you ‘consume’ Register - call when done Saturday, November 10, 12
  8. No black magic Specify dependency model Feed architect a config

    file Call ‘createApp’ Saturday, November 10, 12
  9. Options Passed in at startup Options can be dependencies Fail

    if options aren’t present Saturday, November 10, 12
  10. chunks of functionality Implicit type constraints Keep implementation private Swap

    features instead of interfaces Saturday, November 10, 12
  11. How does Cloud9 use it? Open source version Local version

    (OS + sync) Hosted version Normal FTP SSH Saturday, November 10, 12
  12. Swap feature per implementation On OSS: talk local filesystem On

    FTP: talk FTP library On SSH: talk via a SSH bridge Saturday, November 10, 12
  13. IDE instance (FTP) IDE instance (SSH) IDE instance (Normal) IDE

    instance (Normal) Single node.js process Other code (dashboard etc.) Saturday, November 10, 12
  14. Architect can do Multiple instances of same plugin Run independently

    But in the same process Saturday, November 10, 12
  15. Centralized event bus Loose coupling between plugins No hard dependencies!

    Can also do inter-context communication Saturday, November 10, 12
  16. And now scale Swap it with i.e. Redis PubSub Plugins

    will never notice Modular awesomeness! Saturday, November 10, 12
  17. Modularize in feature blocks Don’t over engineer Don’t create too

    small blocks They aren’t interfaces! Saturday, November 10, 12