SlideShare a Scribd company logo
1 of 81
Download to read offline
large
                           Architecting


                         node.js
                           applications
Monday, October 22, 12
@sergimansilla

Monday, October 22, 12
P ro g ra m
      ☐ C l o u d9 ID E?
      ☐ Grow in g pai n s
      ☐ I n t ro du c i n g Arc hitec t
      ☐ Le ss on s le arn e d


Monday, October 22, 12
Normal developers




Monday, October 22, 12
JavaScript Developer




Monday, October 22, 12
Cloud9 IDE - http://c9.io




Monday, October 22, 12
Real
                         debugging




Monday, October 22, 12
(Smart!)
                         Code completion



Monday, October 22, 12
Static
                         analysis



Monday, October 22, 12
Free
                         Linux

Monday, October 22, 12
                         VM
Bring your own machine
Monday, October 22, 12
Real terminal




Monday, October 22, 12
Collaboration



Monday, October 22, 12
See each other type
              Debug together
              Productivity++
Monday, October 22, 12
Create
                         Deploy                      Run/Debug


                             Share            Test


Monday, October 22, 12
P ro g ra m
      ☑ C l o u d9 ID E?
      ☐ Grow in g pai n s
      ☐ I n t ro du c i n g Arc hitec t
      ☐ Le ss on s le arn e d


Monday, October 22, 12
10,000s
                         LOC
                         of JavaScript
Monday, October 22, 12
dynamic,
                           weakly
                         typed
                           language
Monday, October 22, 12
one
                         single
Monday, October 22, 12
                         thread
Openshift
       Cloud9 datacenter
                                      Remote VM


                         IDE server   Remote VM


                                      Remote VM



Monday, October 22, 12
Pure madness



Monday, October 22, 12
Modularization
Monday, October 22, 12
Black
                         box
                           coding
Monday, October 22, 12
Monday, October 22, 12
Java/.NET      import(s)


            Node.js      require


Monday, October 22, 12
Great for
      re
 requi




                         abstracting

Monday, October 22, 12
                         away
re
 requi



                         Not Great for
                         application
                         modularity
Monday, October 22, 12
re
 requi



                         Relies on FS
                           duplicated modules
                          maps to folder names
                         Hard to configure module

Monday, October 22, 12
Dependency error handling

     coding time           compile time   run time
                                                          !
                                                        OM
                                                - BO
                                          KA

                                          - Server crash
                                          - Unhappy customers
                                          - Developer gets fired




Monday, October 22, 12
How to fix it?

       Static dependency list         Resolve at startup
       Named services                 No FS required
       Easy configuration             Pass an object



Monday, October 22, 12
P ro g ra m
      ☑ C l o u d9 ID E?
      ☑ G row i n g pai n s
      ☐ I n t ro du c i n g Arc hitec t
      ☐ Le ss on s le arn e d


Monday, October 22, 12
Architect




                         github.com/c9/architect

Monday, October 22, 12
Architect

             Everything is a plugin
             Plugins can consume plugins
             An application is just a set of plugins

Monday, October 22, 12
Dependency model

                     require          runtime
                   Architect      compile time

Monday, October 22, 12
Dependency error handling
                               Architect
  coding time             compile time              run time




                                                    - Happy customers
                           - Fails before release   - Developer keeps job



Monday, October 22, 12
Monday, October 22, 12
Declare entity ‘presenter’ with behavior
       Use ‘presenter’ to do a presentation



Monday, October 22, 12
Dependency model


                         Presenter             Presentation




Monday, October 22, 12
Express our model
                             package.json

                           Builds dependency tree

                           without
                           executing code
Monday, October 22, 12
Monday, October 22, 12
What’s next?

      Wrap in Architect plugin code
      Extract the code
      Make two plugins


Monday, October 22, 12
Function
                                signature




                         Call when done
Monday, October 22, 12
Architect plugin code
Module.exports
               Options - we’ll get to that
               Imports - everything you ‘consume’
               Register - invoke when done

Monday, October 22, 12
Monday, October 22, 12
Monday, October 22, 12
Easy to test
                              Mock dependencies



Monday, October 22, 12
Assert ‘dance’ is called 11 times




Monday, October 22, 12
No black magic

                Specify dependency model
      Feed architect a config file
                 Call ‘createApp’

Monday, October 22, 12
Monday, October 22, 12
Monday, October 22, 12
Configuration

                Per-plugin options
                No global options object
                Specify in config file

Monday, October 22, 12
Monday, October 22, 12
Monday, October 22, 12
Options

                         Automatically passed in at startup
      Options are also dependencies
                               Fail if options aren’t present

Monday, October 22, 12
Monday, October 22, 12
Monday, October 22, 12
Architect makes you think of your app as
          chunks of functionality
        rather than sets of classes


Monday, October 22, 12
Think ‘chunks of functionality’

           Implicit type constraints
                                Keep implementation private
           Swap features instead of interfaces

Monday, October 22, 12
How does Cloud9 use it?
                Open source version
                Local version (OS + sync)
                Hosted version
                         Normal
                         FTP
                         SSH
Monday, October 22, 12
Monday, October 22, 12
Swap feature per
                               implementation
                         On Open source: talk local filesystem
                         On FTP: talk FTP library
                         On SSH: talk via a SSH bridge

Monday, October 22, 12
Here is something your
                          DI framework can’t do


Monday, October 22, 12
Single node.js process


                                        IDE instance   IDE instance
                                           (FTP)          (SSH)
                       Other code
                     (dashboard etc.)
                                        IDE instance   IDE instance
                                          (Normal)       (Normal)




Monday, October 22, 12
Monday, October 22, 12
Architect can do

             Multiple instances of same plugin
                             Run independently
             But in the same process


Monday, October 22, 12
Monday, October 22, 12
Monday, October 22, 12
HERE’S SOMETHING COOL




Monday, October 22, 12
Centralized eventbus

       Loose coupling between plugins
       No hard dependencies!
       Can also do inter-context communication


Monday, October 22, 12
React on event
                Other plugin




                                                Event
                                                 bus



                                                        Emit event
                                                                     Plugin


Monday, October 22, 12
Monday, October 22, 12
Monday, October 22, 12
And now scale up

       Need something inter-server
       Swap it with i.e. Redis PubSub
       Plugins will never notice
       Modular awesomeness!

Monday, October 22, 12
P ro g ra m
      ☑ C l o u d9 ID E?
      ☑ G row i n g pai n s
      ☑ I n t ro du c i n g Arc hitec t
      ☐ Le sson s learn ed


Monday, October 22, 12
Modularize in feature blocks

                Don’t over engineer
                Don’t create too small blocks
                They aren’t interfaces!

Monday, October 22, 12
Use dependency injection

                Architect (JavaScript)
                StructureMap (.NET)
                Spring (Java)

Monday, October 22, 12
Avoid context switching

                Less code!
                Less errors!
                Less boilerplate!

Monday, October 22, 12
Loose coupling

                         Use an event bus
                         Smaller dependency graph



Monday, October 22, 12
github.com/c9/architect

Monday, October 22, 12
Happy coding!


Monday, October 22, 12
http://c9.io

                                            Sergi Mansilla
                                         @sergimansilla
                                        github.com/sergi
Monday, October 22, 12

More Related Content

What's hot

What's hot (20)

DNS Security
DNS SecurityDNS Security
DNS Security
 
DNS Presentation
DNS PresentationDNS Presentation
DNS Presentation
 
CouchDB
CouchDBCouchDB
CouchDB
 
Dns
DnsDns
Dns
 
HCL Notes and Nomad Troubleshooting for Dummies
HCL Notes and Nomad Troubleshooting for DummiesHCL Notes and Nomad Troubleshooting for Dummies
HCL Notes and Nomad Troubleshooting for Dummies
 
Getting started with Amazon DynamoDB
Getting started with Amazon DynamoDBGetting started with Amazon DynamoDB
Getting started with Amazon DynamoDB
 
DynamodbDB Deep Dive
DynamodbDB Deep DiveDynamodbDB Deep Dive
DynamodbDB Deep Dive
 
Dns server
Dns server Dns server
Dns server
 
Engage2022 - Domino Admin Tips
Engage2022 - Domino Admin TipsEngage2022 - Domino Admin Tips
Engage2022 - Domino Admin Tips
 
Mongo DB Presentation
Mongo DB PresentationMongo DB Presentation
Mongo DB Presentation
 
Intro to DNS
Intro to DNSIntro to DNS
Intro to DNS
 
25 DNS
25 DNS25 DNS
25 DNS
 
CouchDB
CouchDBCouchDB
CouchDB
 
MongoDB Schema Design and its Performance Implications
MongoDB Schema Design and its Performance ImplicationsMongoDB Schema Design and its Performance Implications
MongoDB Schema Design and its Performance Implications
 
Great new Domino features since 9.0.1FP8.pptx
Great new Domino features since 9.0.1FP8.pptxGreat new Domino features since 9.0.1FP8.pptx
Great new Domino features since 9.0.1FP8.pptx
 
Security of DNS
Security of DNSSecurity of DNS
Security of DNS
 
Cassandra Data Model
Cassandra Data ModelCassandra Data Model
Cassandra Data Model
 
Ch1 internet Networks
Ch1 internet NetworksCh1 internet Networks
Ch1 internet Networks
 
Hadoop basic commands
Hadoop basic commandsHadoop basic commands
Hadoop basic commands
 
DNS server configuration
DNS server configurationDNS server configuration
DNS server configuration
 

Similar to Architecting large Node.js applications

A Morning with MongoDB Barcelona: Introduction
A Morning with MongoDB Barcelona: IntroductionA Morning with MongoDB Barcelona: Introduction
A Morning with MongoDB Barcelona: Introduction
MongoDB
 
Building businesspost.ie using Node.js
Building businesspost.ie using Node.jsBuilding businesspost.ie using Node.js
Building businesspost.ie using Node.js
Richard Rodger
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?
Ovidiu Dimulescu
 
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Patrick Chanezon
 
Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main
Introduction to Docker and Linux Containers @ Cloud Computing Rhein MainIntroduction to Docker and Linux Containers @ Cloud Computing Rhein Main
Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main
Puja Abbassi
 

Similar to Architecting large Node.js applications (20)

The Web Designers Toolkit
The Web Designers ToolkitThe Web Designers Toolkit
The Web Designers Toolkit
 
Aegir
AegirAegir
Aegir
 
Inbound Marketing and WordPress
Inbound Marketing and WordPressInbound Marketing and WordPress
Inbound Marketing and WordPress
 
Big app design for Node.js
Big app design for Node.jsBig app design for Node.js
Big app design for Node.js
 
A Morning with MongoDB Barcelona: Introduction
A Morning with MongoDB Barcelona: IntroductionA Morning with MongoDB Barcelona: Introduction
A Morning with MongoDB Barcelona: Introduction
 
Down the Rabbit Hole: Getting Started with the DITA Open Toolkit
Down the Rabbit Hole: Getting Started with the DITA Open Toolkit Down the Rabbit Hole: Getting Started with the DITA Open Toolkit
Down the Rabbit Hole: Getting Started with the DITA Open Toolkit
 
REST & Hypermedia: the missing links and why you need them - Ruby Hoedown 2012
REST & Hypermedia: the missing links and why you need them - Ruby Hoedown 2012REST & Hypermedia: the missing links and why you need them - Ruby Hoedown 2012
REST & Hypermedia: the missing links and why you need them - Ruby Hoedown 2012
 
Building businesspost.ie using Node.js
Building businesspost.ie using Node.jsBuilding businesspost.ie using Node.js
Building businesspost.ie using Node.js
 
Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013
 
Web development, from git flow to github flow
Web development, from git flow to github flowWeb development, from git flow to github flow
Web development, from git flow to github flow
 
Agile V2
Agile V2Agile V2
Agile V2
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?
 
Html5 new sword for interactive app
Html5 new sword for interactive appHtml5 new sword for interactive app
Html5 new sword for interactive app
 
Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry Bootcamp
 
Cloud foundry and openstackcloud
Cloud foundry and openstackcloudCloud foundry and openstackcloud
Cloud foundry and openstackcloud
 
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
 
The Design of Everyday Things
The Design of Everyday ThingsThe Design of Everyday Things
The Design of Everyday Things
 
Cloudera Desktop
Cloudera DesktopCloudera Desktop
Cloudera Desktop
 
A Morning with MongoDB Barcelona: Use Cases and Roadmap
A Morning with MongoDB Barcelona: Use Cases and RoadmapA Morning with MongoDB Barcelona: Use Cases and Roadmap
A Morning with MongoDB Barcelona: Use Cases and Roadmap
 
Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main
Introduction to Docker and Linux Containers @ Cloud Computing Rhein MainIntroduction to Docker and Linux Containers @ Cloud Computing Rhein Main
Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Architecting large Node.js applications