Big app design for Node.js
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Big app design for Node.js

  • 2,568 views
Uploaded on

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......

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.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,568
On Slideshare
2,565
From Embeds
3
Number of Embeds
1

Actions

Shares
Downloads
27
Comments
0
Likes
5

Embeds 3

http://nodeslide.herokuapp.com 3

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. BIG application designSaturday, November 10, 12
  • 2. @sergimansillaSaturday, November 10, 12
  • 3. http://c9.ioSaturday, November 10, 12
  • 4. Smart code completionSaturday, November 10, 12
  • 5. Static analysisSaturday, November 10, 12
  • 6. Free linux VMSaturday, November 10, 12
  • 7. Bring your own machineSaturday, November 10, 12
  • 8. Real terminalSaturday, November 10, 12
  • 9. Hundreds of thousands of lines of JavaScriptSaturday, November 10, 12
  • 10. dynamic, weakly-typed languageSaturday, November 10, 12
  • 11. one single threadSaturday, November 10, 12
  • 12. Openshift Cloud9 datacenter Remote VM Remote IDE server VM Remote VMSaturday, November 10, 12
  • 13. Saturday, November 10, 12
  • 14. Saturday, November 10, 12
  • 15. ModularizationSaturday, November 10, 12
  • 16. Black box codingSaturday, November 10, 12
  • 17. Saturday, November 10, 12
  • 18. re requi Good at abstracting awaySaturday, November 10, 12
  • 19. re requi Not that good at app-level abstractionSaturday, November 10, 12
  • 20. re requi Relies on FS duplicated modules maps to folder names hard to configure moduleSaturday, November 10, 12
  • 21. Dependency error handling coding time compile time run time ! OM - BO KA - Server crash - Unhappy customers - Developer gets firedSaturday, November 10, 12
  • 22. How to fix it? Static dependency list Resolve at startup Named services No FS required Easy configuration Pass an objectSaturday, November 10, 12
  • 23. Architect github.com/c9/architectSaturday, November 10, 12
  • 24. Architect Everything is a plugin Plugins can consume plugins An application is just a set of pluginsSaturday, November 10, 12
  • 25. Dependency model require runtime Architect compile timeSaturday, November 10, 12
  • 26. Dependency error handling Architect coding time compile time run time - Happy customers - Fails before release - Developer keeps jobSaturday, November 10, 12
  • 27. github.com/sergi/nodejsconfit2012Saturday, November 10, 12
  • 28. Saturday, November 10, 12
  • 29. Declare entity ‘cook’ with behavior Use ‘cook’ to do some cookingSaturday, November 10, 12
  • 30. Dependency model Cooking Cook actionSaturday, November 10, 12
  • 31. package.json Builds dependency tree without executing codeSaturday, November 10, 12
  • 32. cook/package.json { do-­‐cooking/package.json {Saturday, November 10, 12
  • 33. Next Wrap in Architect plugin code Extract the code Make two pluginsSaturday, November 10, 12
  • 34. Function signature Call when doneSaturday, November 10, 12
  • 35. Architect plugin codeModule.exports Options - we’ll talk about it later Imports - everything you ‘consume’ Register - call when doneSaturday, November 10, 12
  • 36. Saturday, November 10, 12
  • 37. Saturday, November 10, 12
  • 38. Easy to test Mock dependenciesSaturday, November 10, 12
  • 39. ‘cook’ should be called 8 timesSaturday, November 10, 12
  • 40. No black magic Specify dependency model Feed architect a config file Call ‘createApp’Saturday, November 10, 12
  • 41. Saturday, November 10, 12
  • 42. Saturday, November 10, 12
  • 43. Configuration Per-plugin options No global options object Specify in config fileSaturday, November 10, 12
  • 44. Saturday, November 10, 12
  • 45. Saturday, November 10, 12
  • 46. Options Passed in at startup Options can be dependencies Fail if options aren’t presentSaturday, November 10, 12
  • 47. Saturday, November 10, 12
  • 48. Saturday, November 10, 12
  • 49. Your app as chunks of functionality rather than sets of classesSaturday, November 10, 12
  • 50. chunks of functionality Implicit type constraints Keep implementation private Swap features instead of interfacesSaturday, November 10, 12
  • 51. How does Cloud9 use it? Open source version Local version (OS + sync) Hosted version Normal FTP SSHSaturday, November 10, 12
  • 52. Saturday, November 10, 12
  • 53. Swap feature per implementation On OSS: talk local filesystem On FTP: talk FTP library On SSH: talk via a SSH bridgeSaturday, November 10, 12
  • 54. Architect is a DI frameworkSaturday, November 10, 12
  • 55. But a quite special oneSaturday, November 10, 12
  • 56. Single node.js process IDE instance IDE instance (FTP) (SSH) Other code (dashboard etc.) IDE instance IDE instance (Normal) (Normal)Saturday, November 10, 12
  • 57. Architect can do Multiple instances of same plugin Run independently But in the same processSaturday, November 10, 12
  • 58. Centralized event bus Loose coupling between plugins No hard dependencies! Can also do inter-context communicationSaturday, November 10, 12
  • 59. React on event Other plugin Event bus Emit event PluginSaturday, November 10, 12
  • 60. Saturday, November 10, 12
  • 61. Saturday, November 10, 12
  • 62. And now scale Swap it with i.e. Redis PubSub Plugins will never notice Modular awesomeness!Saturday, November 10, 12
  • 63. Modularize in feature blocks Don’t over engineer Don’t create too small blocks They aren’t interfaces!Saturday, November 10, 12
  • 64. Avoid context switching Less code! Less errors! Less boilerplate!Saturday, November 10, 12
  • 65. Loose coupling Use (don’t abuse) an event bus Smaller dependency graphSaturday, November 10, 12
  • 66. github.com/c9/architectSaturday, November 10, 12
  • 67. Happy coding!Saturday, November 10, 12
  • 68. http://c9.io @sergimansilla github.com/sergiSaturday, November 10, 12