IBM and Node.js - Old Doge, New Tricks
-
Upload
dejan-glozic -
Category
Software
-
view
849 -
download
0
description
Transcript of IBM and Node.js - Old Doge, New Tricks
![Page 1: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/1.jpg)
IBM and Node.js: Old Doge, New Tricks
Dejan Glozic, Full-Stack Architect, IBM Bluemix DevOps
![Page 2: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/2.jpg)
Show Us Your Stack
![Page 3: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/3.jpg)
About MeIBM Canada Toronto Lab
Full-Stack ArchitectIBM Bluemix DevOps
@dglozichttp://dejanglozic.com
![Page 4: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/4.jpg)
What I Work On
![Page 5: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/5.jpg)
Part 1Motivation for change
![Page 6: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/6.jpg)
Enterprise productsYearly release cycle, moves at the speed of the slowest component.
![Page 7: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/7.jpg)
Large teamsComplex coordination, large change sets, difficult to get a good stable build.
![Page 8: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/8.jpg)
Products run on premiseManaged by customer admins, limited control over hardware choices.
![Page 9: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/9.jpg)
Enterprise stacksJava Enterprise Something Something, WS*, Apache, SQL
![Page 10: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/10.jpg)
Overindulgence in JavaScript‘Extreme Ajax’ - Dojo/Dijit pushed well beyond sane limits
desktop != server != client
![Page 11: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/11.jpg)
A Need for a Reset
• Complexity and crud built up over time
• Apollo 13: sooner or later you hit 12 amps
• Solution: turn everything off and and start from scratch
![Page 12: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/12.jpg)
Motivators
• New attractive stacks built for humans
• The need to bring the fun back
• The need to built ‘fit for cloud’ software
• The need to ‘do it right this time’
![Page 13: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/13.jpg)
Evolution of Thought
• 12-factors
• Netflix
• Reactive Manifesto
• Micro-services
![Page 14: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/14.jpg)
Part 2From Dojo/Dijit to jQuery/Bootstrap/MV*
JS
![Page 15: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/15.jpg)
Client Side ResetSwapping Dojo/Dijit for jQuery/Bootstrap. No point arguing with gravity.
![Page 16: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/16.jpg)
BootstrapWe love the emphasis on HTML5/CSS and away from JavaScript.
![Page 17: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/17.jpg)
After jQuery?
• Sometimes jQuery is too big
• Alternatives for newer browsers: zepto, jqLite
• Or nothing? http://youmightnotneedjquery.com
![Page 18: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/18.jpg)
Part 3From Java to Node.js
JS
![Page 19: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/19.jpg)
Now The Server SideNothing much wrong with servlets and JSPs, but we wanted more.
![Page 20: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/20.jpg)
Sitting on the Node.js Fence
• We watched cautious companies like Walmart and PayPal jump in.
• After plugging the ‘Walmart leak’, it looked like Node.js was ready.
• We were ready to jump ourselves by January 2014.
![Page 21: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/21.jpg)
‘Control Your Urges’ RuleWe will use a new technology to solve a real problem, not as an excuse to play
with the new hotness.
![Page 22: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/22.jpg)
Our Case for Node.js
• We wanted to build a UI for a delivery pipeline
• The pipeline had a number of moving parts
• We didn’t want to poll the server to the ground
• Solution: Node.js + WebSockets (via Socket.io)
![Page 23: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/23.jpg)
Unlocking New Opportunities
• With Node.js, we could run JavaScript templating engine for the V of MVC
• We chose Dust.js because LinkedIn, PayPal, Yahoo, Netflix
• Bonus: we can now run Dust partials on the client as well (demo spoiler)
![Page 24: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/24.jpg)
Part 4From a monolith to micro-services
![Page 25: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/25.jpg)
Tackling the Hard ProblemsSo far we upgraded our stack but didn’t handle any of our systemic problems.
![Page 26: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/26.jpg)
Architectural ImpasseIf monoliths were pain for on-premise products, they were killing us in the cloud.
![Page 27: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/27.jpg)
Cloud Imposter RuleStanding up a traditional product in a VM does not mean you ‘solved the cloud’.
![Page 28: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/28.jpg)
Putting Manifestos To WorkThis is where the principles of micro-services, reactive manifesto and 12 factors
come into play.
![Page 29: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/29.jpg)
How Micro-Services Help
• Many micro-services instead of a monolith
• Deploy micro-services independently
• Communicate using message queues
• Cluster locally
![Page 30: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/30.jpg)
This Is Not A Micro-Service TalkThere are others at this conference, and tons of material online.
![Page 31: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/31.jpg)
Part 5From REST to REST+Messaging
![Page 32: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/32.jpg)
What Monolith Giveth, Micro-Service Taketh Away
In-process, we just add event listeners to objects. Between processes, we need a distributed event notification.
![Page 33: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/33.jpg)
Event Collaboration• Instead of polling using REST, react to
events
• Instead of peer to peer, publish without knowing your subscribers
• Message broker smooths out throughput mismatches
• Message broker can hold onto messages
![Page 34: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/34.jpg)
REST/MQ Mirroring• Yin and Yang of micro-service communication
• API services own state
• MQ broadcasts stage changes on matching topics
• Example:
• DELETE /v1/projects/ffya14
• Subscribe to: /v1/projects/+ (MQTT)
• Message body:{ “event”: “deleted” }
![Page 35: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/35.jpg)
Messaging and Clustering
![Page 36: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/36.jpg)
Part 6From SQL to, well, NoSQL (duh)
![Page 37: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/37.jpg)
Our Data is AggregateIt is a pain to join data from a number of tables using foreign keys
![Page 38: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/38.jpg)
Our Integration Points Are API Services
Persistance is implementation detail.
![Page 39: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/39.jpg)
JavaScript All The Way DownWith Node.js, JSON-based NoSQL DB like CouchDB is a natural choice.
![Page 40: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/40.jpg)
Pulling It All Together
![Page 41: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/41.jpg)
Part 7No free lunch - micro-services introduce new problems.
![Page 42: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/42.jpg)
Latency Needs MitigationKeeping micro-services in co-located VMs, strategic caching (combined with MQ
invalidation).
![Page 43: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/43.jpg)
Guards Against BrownoutsCircuit breakers, using ‘last good values’, exponential back-off. See Netflix libraries
for ideas.
![Page 44: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/44.jpg)
AuthenticationWe need to stay authenticated as we transition between micro-services.
![Page 45: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/45.jpg)
UI CompositionIncluding page fragments is easy in monoliths using partials. In micro-service
systems, we need distributed solutions.
![Page 46: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/46.jpg)
Part 8Lessons from the trenches
![Page 47: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/47.jpg)
Legal Hates Us
• Hundreds of modules to scan licenses and content
• Torrent is now turning into a trickle (phew!)
• Occasional spike (e.g. express 4, Socket.io 1.0)
![Page 48: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/48.jpg)
Ops Hate Us
• Operational complexity
• Many firewall rules for service to service links
• Many proxy_pass rules
• Unknown new platforms and tools (what is ‘PM2’?)
![Page 49: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/49.jpg)
IaaS Too Low for Micro-Services
• Sweet spot - highly customized back-end systems
• Node.js services are a shoe-in for a PaaS
• DBaaS takes away storage management headaches
• We are moving to a PaaS now (Cloud Foundry/Bluemix)
![Page 50: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/50.jpg)
–Dejan’s Razor (in honour of William of Ockham)
“Use the simplest solution you can get away withTM.”
![Page 51: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/51.jpg)
Dejan’s Razor
• If server-side MVC does the job, use it
• If jQuery + Bootstrap do the job, use them
• If adding Backbone.js helps, do it*
• If you really need Angular.js, use it**
![Page 52: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/52.jpg)
*Use Client-Side MVC
• If highly dynamic behaviour is needed and…
• You promise to use pushState (no # or #!) and…
• You promise to send initial content from the server…
• You promise to watch the client JS size
![Page 53: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/53.jpg)
**Use Angular.js
• If all the rules for client-side MVC apply and…
• You promise not to leave us to maintain 1.3 when 2.0 comes out
![Page 54: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/54.jpg)
Micro-Service BenefitWe can apply Dejan’s Razor on each service independently. Each service can be
only as smart as needed for the task at hand.
![Page 55: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/55.jpg)
DEMO
![Page 56: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/56.jpg)
The Devil Is In The PuddingNginxNginx
HomeHome IsomorphicIsomorphic Server PushServer Push Angular Seed
Angular Seed HeaderHeader
RedisRedis RabbitMQRabbitMQ
//about
/ isomorphic /server-push /angular-seed
/page1/page2
OAuth2 provider
![Page 57: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/57.jpg)
How To Follow
• Source code on GitHub: https://github.com/dglozic/fsto-demo
• Hosted on Bluemix: http://fsto-demo.mybluemix.net
![Page 58: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/58.jpg)
Q/A?
![Page 59: IBM and Node.js - Old Doge, New Tricks](https://reader033.fdocuments.net/reader033/viewer/2022060122/559620121a28ab8b0e8b4875/html5/thumbnails/59.jpg)
Thank you!Follow me on Twitter: @dglozicRead my blog: dejanglozic.com