node summit workshop
TRANSCRIPT
Shubhra Kar | Products & Education twitter:@shubhrakar mail:[email protected]
Frameworks or a Design Pattern ?
These guys sent me !
Bert Belder
Ben Noordhuis
Node Core
Raymond Feng
Ritchie Martori
LoopBack / Express Core
Sam Roberts
Miroslav Bajtos
Ryan Graham
Plus 15 other full-time open source developers working on Node.js core, modules and tools. Contributing to over 100 open source modules. Supporting banks, retail, IoT companies, startups and internet companies on Node.js
Patterns are not created, they evolve
Right Now
— Someone on Stage
Pattern : DIY
StrongLoop Confidential and Proprietary Information – © 2015
u Un-opinionated u Middleware u Use case centric
u Express: Web Templating u Restify: REST API
u Low learning curve u Restify: Dtrace Support u Manual CRUD/Testing/ Refactoring
Pattern : Configuration
u Pseudo Opinionated u Configuration over Convention u Granular HTTP/WebServer control u Supported and well documented u DIY challenges of manual CRUD/Refactor/Testing
StrongLoop Confidential and Proprietary Information – © 2015
Pattern: ORM & Isomorphic JS
u Model Driven Development u Any data source u Isomorphic JS
u Omni-Channel u Share Models (Client/
Server) u Loopback u Meteor
u Automatic REST API generation u Higher learning curve
StrongLoop Confidential and Proprietary Information – © 2015
Pattern: API Economy and mobile-IoT proliferation
Explosion of channels (browsers, mobile, sensors, wearable, real-time communication)
u Sheer number of clients has increased
u Clients are increasingly sophisticated
u Node.js is the platform of choice for these API
StrongLoop Confidential and Proprietary Information – © 2015
Latency demands are uncompromising
10
25
50
100 100
50
10 1 5
40
100
25
Web SaaS Mobile IoT
The new curve Concurrent Users Latency Adoption
StrongLoop Confidential and Proprietary Information – © 2015
Analyze, Analyze, Analyze
Not all APIs are built equal
The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.
Relational Database Clustered Database Security Gateway Cloud Firewall SOA Bus ( not sure on this one)
Laptop ( not requested but useful)
Connections
Tablet Phone IoT SDK API SERVER Items for ACL
Quick Example of Use
App Server Add On
App Server
Relational Database Clustered Database Security Gateway Cloud Firewall SOA Bus ( not sure on this one)
Laptop ( not requested but useful)
Connections
Tablet Phone IoT SDK API SERVER Items for ACL
Quick Example of Use
App Server Add On
App Server
X – Backend ?
X - Channel
X - Platform
API Neutrality
Mainframe to Mobile ?
StrongLoop Confidential and Proprietary Information – © 2015
API “Re-Composition” is good…but not good enough
Relational Database Clustered Database Security Gateway Cloud Firewall SOA Bus ( not sure on this one)
Laptop ( not requested but useful)
Connections
Tablet Phone IoT SDK API SERVER Items for ACL
Quick Example of Use
App Server Add On
App Server
Relational Database Clustered Database Security Gateway Cloud Firewall SOA Bus ( not sure on this one)
Laptop ( not requested but useful)
Connections
Tablet Phone IoT SDK API SERVER Items for ACL
Quick Example of Use
App Server Add On
App Server
Auth Routing Rate-Limit Proxy Mediation Orchestration Analytics
StrongLoop Confidential and Proprietary Information – © 2015
The need is “DE-COMPOSITION”
SaaS Mobile IoT Web
App Server API Server
HTML JSON
{JSON} {JSON}
{JSON}
<SOAP/XML>
<TABLE>
StrongLoop Confidential and Proprietary Information – © 2015
Micro-services has arrived
StrongLoop Confidential and Proprietary Information – © 2015
Now I know !!!
StrongLoop Open source iPaaS (Arc)
StrongLoop Confidential and Proprietary Information – © 2015
REST API
PUSH
GEO OFF SYNC
DEVICE
USER FILE
Relational Database Clustered Database Security Gateway Cloud Firewall SOA Bus ( not sure on this one)
Laptop ( not requested but useful)
Connections
Tablet Phone IoT SDK API SERVER Items for ACL
Quick Example of Use
App Server Add On
App Server
Storage
Relational Database Clustered Database Security Gateway Cloud Firewall SOA Bus ( not sure on this one)
Laptop ( not requested but useful)
Connections
Tablet Phone IoT SDK API SERVER Items for ACL
Quick Example of Use
App Server Add On
App Server
REST
API GATEWAY
Channel SDKs
API ENGINE
CONNECTORs
API
SDKs
Loopback open source Enterprise ORM framework
REST API
Relational Database Clustered Database Security Gateway Cloud Firewall SOA Bus ( not sure on this one)
Laptop ( not requested but useful)
Connections
Tablet Phone IoT SDK API SERVER Items for ACL
Quick Example of Use
App Server Add On
App Server
API Explorer
Marquee Features
u Discovery
u Migration / Replication
u Relationship Mapping
u Mixins - Aggregation
u Access Control
u User Management
u Isomorphic JS / Remoting u Routing
StrongLoop Confidential and Proprietary Information – © 2014
{“..”} JSON is the new first class citizen
StrongLoop Confidential and Proprietary Information – © 2014
Data & Services Integration
Services
Relational Database Clustered Database Security Gateway Cloud Firewall SOA Bus ( not sure on this one)
Laptop ( not requested but useful)
Connections
Tablet Phone IoT SDK API SERVER Items for ACL
Quick Example of Use
App Server Add On
App Server
Storage
Relational Database Clustered Database Security Gateway Cloud Firewall SOA Bus ( not sure on this one)
Laptop ( not requested but useful)
Connections
Tablet Phone IoT SDK API SERVER Items for ACL
Quick Example of Use
App Server Add On
App Server
REST
Messaging
Database
NoSQL
Marquee - Discovery & Migration !
StrongLoop Confidential and Proprietary Information – © 2014
User Experience
Arc UI – architect view – Widget driven – Visual composition,
management & operations – Marquee featured, evolving
platform
StrongLoop Console (slc) - developer view – Command Line Interface – Full featured – Greater customization support
StrongLoop Confidential and Proprietary Information – © 2014
API Explorer (Swagger) – Iterative build and test w/o frontend
StrongLoop Confidential and Proprietary Information – © 2014
API Gateway *
Security & Social Logins
* Evolving. Please do not share without written consent from StrongLoop
Marquee – Auth, Routing, Throttling, Proxy, Mediation, Aggregation, Virtualization
StrongLoop Confidential and Proprietary Information – © 2014
Developer SDKs
Omni-channel Client SDKs
JS client
JS Server
Remoting
JS client
Marquee – Isomorphic JS, Mobile Integration
StrongLoop Confidential and Proprietary Information – © 2014
Mobile Services: Offline Sync
StrongLoop Confidential and Proprietary Information – © 2014
Mobile Services: Push Notification
StrongLoop Confidential and Proprietary Information – © 2014
Mobile Services: GeoLocation
Coding Time
StrongLoop Confidential and Proprietary Information – © 2015
Debugging Marquee – Chrome Dev Tools, Remote
StrongLoop Confidential and Proprietary Information – © 2014
Memory Leaks ?
StrongLoop Confidential and Proprietary Information – © 2015
heapdump for V8 snapshots by @bnoordhuis
npm install heapdump Add to app : var heapdump = require(‘heapdump’)
Method 1 : writeSnapshot
Method 2 : SIGUSR2 (Unix only)
Make sure your directory is writable
var heapdump = require('heapdump') ... heapdump.writeSnapshot()
kill –USR2 <pid>
process.chdir('/path/to/writeable/dir’)
StrongLoop Confidential and Proprietary Information – © 2015
heapdump for V8 snapshots by @bnoordhuis Programmatic heap snapshots (timer based)
Programmatic heap snapshots (threshold based)
var heapdump = require('heapdump') ... setInterval(function () { heapdump.writeSnapshot() }, 6000 * 30) <strong>(1)</strong>
var heapdump = require('heapdump') var nextMBThreshold = 0 <strong>(1)</strong> setInterval(function () { var memMB = process.memoryUsage().rss / 1048576 <strong>(2)</strong> if (memMB > nextMBThreshold) { <strong>(3)</strong> heapdump.writeSnapshot() nextMBThreshold += 100 } }, 6000 * 2) <strong>(4)</strong>
StrongLoop Confidential and Proprietary Information – © 2015
We have made it simpler in Arc – Remote heaps
StrongLoop OSS - HeapSnapshots slc runctl heap-snapshot ID
CPU’s smoke too !
StrongLoop Confidential and Proprietary Information – © 2015
CPU profiler : slc cpu-start/stop or just slc arc
StrongLoop Confidential and Proprietary Information – © 2015
How we fixed a real production problem
Don’t Block the EventLoop
StrongLoop Confidential and Proprietary Information – © 2015
Blocked event loop in Meteor atmosphere
node-fibers implements co-routines. Meteor uses this to hack local thread storage allowing V8 to run multiple execution contexts each mapped to a co-routine.
FindOrAllocatePerThreadDataForThisThread() used in switching context between co-routines
Co-routines are cooperative; the current coroutine has to yield control before another one can
run and that is what Meteor does in its process.nextTick() callback; it essentially builds concurrent (but not parallel) green threads on a round-robin scheduler
Too many tiny tasks and not one long running one was blocking the event loop
process.nextTick() has a failsafe mechanism where it will process “x” tick callbacks before deferring the remaining ones to the next event loop tick.
Native MongoDB driver disabled the failsafe to silence a warning message in node v0.10 about
maxtickDepth being reached
ticks parent name 2274 7.3% v8::internal::Isolate::FindOrAllocatePerThreadDataForThisThread() 1325 58.3% LazyCompile: ~<anonymous> packages/meteor.js:683 1325 100.0% LazyCompile: _tickCallback node.js:399
The solution
The workaround: switch fromprocess.nextTick() to setImmediate()
Performance Monitoring
StrongLoop Confidential and Proprietary Information – © 2015
Production Monitoring & 3rd Party integration
• Local / Hosted • Graphite • Splunk • Datadog • CA Introscope
StrongLoop Confidential and Proprietary Information – © 2014
Dynamic Instrumentation
Agent App Monkey Patching
Agent App Dynamic Instrument
• Live Edit • Line Level
Instrumentation • Any package, any
framework, any code
• Custom logic • HA rollback
StrongLoop Confidential and Proprietary Information – © 2015
Process Management & HyperScaling
StrongLoop Confidential and Proprietary Information – © 2015
Private Registry & Build
StrongLoop Confidential and Proprietary Information – © 2015
Build & Deploy
StrongLoop Confidential and Proprietary Information – © 2014
Cluster and runtime scaling Marquee – HA, Auto-scale, Hot Deploy
StrongLoop Confidential and Proprietary Information – © 2014
MESH – Micro-services Deploy on Scale
StrongLoop Confidential and Proprietary Information – © 2014
First there was Node
Thank you!
JUST WIN,BABY!