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.
18. re
requi
Good at
abstracting away
Saturday, November 10, 12
19. re
requi
Not that good at
app-level abstraction
Saturday, November 10, 12
20. re
requi
Relies on FS
duplicated modules
maps to folder names
hard to configure module
Saturday, November 10, 12
21. Dependency error handling
coding time compile time run time
!
OM
- BO
KA
- Server crash
- Unhappy customers
- Developer gets fired
Saturday, November 10, 12
22. How to fix it?
Static dependency list Resolve at startup
Named services No FS required
Easy configuration Pass an object
Saturday, November 10, 12
23. Architect
github.com/c9/architect
Saturday, November 10, 12
24. Architect
Everything is a plugin
Plugins can consume plugins
An application is just a set of
plugins
Saturday, November 10, 12
25. Dependency model
require runtime
Architect compile time
Saturday, November 10, 12
26. Dependency error handling
Architect
coding time compile time run time
- Happy customers
- Fails before release - Developer keeps job
Saturday, November 10, 12
31. package.json
Builds dependency tree
without
executing code
Saturday, 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 plugins
Saturday, November 10, 12
34. Function
signature
Call when
done
Saturday, November 10, 12
35. Architect plugin code
Module.exports
Options - we’ll talk about it later
Imports - everything you ‘consume’
Register - call when done
Saturday, November 10, 12
55. But a quite
special one
Saturday, 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 process
Saturday, November 10, 12
58. Centralized event bus
Loose coupling between plugins
No hard dependencies!
Can also do inter-context communication
Saturday, November 10, 12
59. React on event
Other plugin
Event
bus
Emit event
Plugin
Saturday, November 10, 12