Html5 devconf nodejs_devops_shubhra
-
Upload
shubhra-kar -
Category
Software
-
view
203 -
download
1
Transcript of Html5 devconf nodejs_devops_shubhra
![Page 1: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/1.jpg)
Triage, Diagnose & Scale Node.js
Shubhra Kar | Director – Products
twitter:@shubhrakar mail:[email protected]
![Page 2: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/2.jpg)
Why am I here…or rather who sent me here ?
![Page 3: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/3.jpg)
These guys sent me !
Bert
Belder
Ben
Noordhuis
Node Core
Raymond
FengRitchie
Martori
LoopBack/Express Core
Sam
Roberts
Miroslav
Bajtos
Ryan
Graham
![Page 4: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/4.jpg)
To do what ?
To give you a fresh pair of gloves
![Page 5: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/5.jpg)
Let’s revisit the STORY
Let’s touch up our
SOA for
Mobile…and bring
Glass @ work
Architect Developer
![Page 6: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/6.jpg)
The boss does have valid questions
I recommend
Node.js for our
API strategy
Architect The Boss
Node is nerdy like systems
programming !...Where are
tools ? Do we have an IDE ?
![Page 7: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/7.jpg)
Node.js APIs actually have a life cycle
8
Compose
Deploy / Scale
Monitor
Secure / Manage
API Studio Controller StrongOps API Gateway
Development Production
Reliable API Solutions powered by Node.js
![Page 8: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/8.jpg)
Let’s start by debugging
• Chrome debugger
• Debug Remotely on
Production
• Breakpoints &
uncaught exceptions
• Source Maps
• Unit test integration
• Display/edit variables
• Pre-loaded breaks
Known as Node-Inspector / StrongLoop-Debug
![Page 9: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/9.jpg)
Debugging server side clustered apps
slc debug app.js
Debugging single process
slc debug app.js
http://localhost:8080/debug?port=<5858+ID-of-process>
Debugging clustered process in V11
%node debug –p <PID>
connecting…ok
…
debug>quit
%node-inspector
http://127.0.0.1:8080/debug?port =5858
Or
process._debugPort = 5858 + cluster.worker.id
Debugging clustered process in V10
![Page 10: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/10.jpg)
Can Errors be stitched into a trace and recovered ?
Enter StrongLoop / Zones
![Page 11: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/11.jpg)
But is it enough to convince him ?
Plus I can now
diagnose CPU
hotspots and Memory
Bottlenecks
Architect The Boss
Node is fast you said
!...what bottlenecks and
leaks ?
![Page 12: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/12.jpg)
How to diagnose CPU hotspots upto line of code ?
Enter StrongLoop OSS - Node Profiler
slc runctl cpu-start/stop PID >> CPU Proc files
![Page 13: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/13.jpg)
Can I visually see my hotspots ?
Chrome Dev Tools – For Server !
![Page 14: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/14.jpg)
How about a fancy chart for my boss ?
Call Stack
Path and
function
CPU Cycle
times
![Page 15: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/15.jpg)
Does Node have memory leaks ?
StrongLoop OSS - HeapSnapshots
slc runctl heap-snapshot PID
![Page 16: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/16.jpg)
heapdump for V8 snapshots
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’)
![Page 17: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/17.jpg)
Heap Snapshot strategies
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>
![Page 18: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/18.jpg)
Another fancy chart please
![Page 19: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/19.jpg)
We are getting there…
See we have
great Dev
Tools
Architect The Boss
Not at 3:00 a.m. in the night
!….Show me its Production
ready
![Page 20: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/20.jpg)
Ok…here is 24x7 monitoring
![Page 21: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/21.jpg)
On-Premises / 3rd Party monitoring ?
22
• Graphite
• Splunk
• Datadog
• Introscope
• Others
![Page 22: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/22.jpg)
And On-Demand Dynamic Instrumentation
Agent AppMonkey
Patching
Agent AppDynamic
Instrument
• Live Edit
• Line Level
Instrumentation
• Any package, any
framework, any code
• Custom logic
• Counters, Gauges and
Timers
• HA rollback
![Page 23: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/23.jpg)
Almost there …
Look I got
monitoring
Architect The Boss
Good…but before I promote
you, show me some scale
![Page 24: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/24.jpg)
Vertical and pseudo-horizontal scaling
• OSS Controller
• Cluster Mgmt.
• Hot Deploy
• Rolling Restart
• Cluster State Mgmt.
• Process Mgmt.
• Deploy
![Page 25: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/25.jpg)
MESH – All things distributed
• Distributed
Deploy
• Cross MC state
• HA
• Docker Containers
• Auto Scaling
• Process Mgmt.
![Page 26: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/26.jpg)
Log Aggregation
• OSS Controller
• Structured Logging
• Log Aggregation
• 3rd Party Integration
![Page 27: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/27.jpg)
That’s how we win.
The Boss
hehe…I am a Node Hipster now !
![Page 28: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/28.jpg)
Nodies are not just silicon valley hipsters !
And most recently….#1 Retailer
![Page 29: Html5 devconf nodejs_devops_shubhra](https://reader030.fdocuments.net/reader030/viewer/2022032616/55a69b3b1a28abe07d8b45c8/html5/thumbnails/29.jpg)
First there was Node
Thank you!
JUST WIN,
BABY!