SlideShare une entreprise Scribd logo
1  sur  34
Télécharger pour lire hors ligne
TRANSACTION TRACING & ROOT
CAUSE ANALYSIS WITH
STRONGLOOP ARC
Jordan Kasper | Developer Evangelist
STEP ONE
The first step in monitoring, profiling, and tracing your
Node application is to run it in a process manager!
BUILD YOUR APP WITH SLC
~$ npm install ­g strongloop
~/my­app$ slc build
...
~/my­app$ ls
... ...  my­app­0.1.0.tgz
INSTALL AND RUN STRONG PM
On your deployment machine...
~$ npm install ­g strong­pm
~$ sl­pm­install
DEPLOY TO STRONG PM
From our development machine (or staging, etc)...
~/my­app$ slc deploy http+ssh://myserver.com:8701
RUNNING LOCALLY
If you need to profile things locally (your machine or a
staging/testing server), run slc start from your app directory:
~/my­app$ slc start
Process Manager is attempting to run app `.`.
  To confirm it is started: slc ctl status tracing­example­app
  To view the last logs: slc ctl log­dump tracing­example­app
  ...
Then start the Arc UI:
~/my­app$ slc arc
METRICS AND MONITORING
VIEWING METRICS
AVAILABLE METRICS
CPU Load (system)
Heap Memory sage
Event Loop Count
Event Loop Tick Timing
HTTP Connections
Database Connections (Oracle, MySQL, Mongo, Postgres)
Misc other modules (Redis, Memcache(d), Message queues)
WHAT DO I LOOK FOR?
CPU Usage is pretty obvious, just watach your high points!
With Heap Memory Usage you want to see a "sawtooth"
chart, each drop indicates garbage collection. No drop is
bad!
WHAT DO I LOOK FOR?
WHAT DO I LOOK FOR?
The two Event Loop metrics are opposed. You want the
loop count to remain high under normal load (more ticks
per metrics cycle is good). Any dips may be bad.
The Loop timing, on the other hand, indicates how long
event loop ticks are taking. Any spikes here are bad!
SETUP METRICS COLLECTION
On our production machine, with strong-pm installed,
simply set the collection location:
~$ export STRONGLOOP_METRICS="log:/path/to/api­metrics.log"
~$ export STRONGLOOP_METRICS="syslog"
~$ export STRONGLOOP_METRICS="statsd://my­log­server.com:1234"
~$ export STRONGLOOP_METRICS="graphite://my­log­server.com:1234"
~$ export STRONGLOOP_METRICS="splunk://my­log­server.com:1234"
SETUP METRICS COLLECTION
Alternatively, on the production machine you can run:
~$ sl­pm­install ­­metrics <url>
Or during runtime:
~$ slc ctl env­set my­app STRONGLOOP_METRICS=<url>
PROFILING
PROFILING
We can spot issues using the metrics being monitored, but
now we need to find the cause of those issues.
Profiling CPU usage and memory is the way to do this.
PROFILING IN ARC
CPU PROFILES
MEMORY PROFILES
PROGRAMMATIC MEMORY MONITORING
If we have memory issues, it may be helpful to monitor
memory usage dynamically.
~$ npm install heapdump ­­save
var heapdump = require('heapdump');
var THRESHOLD = 500;
setInterval(function () {
    var memMB = process.memoryUsage().rss / 1048576;
    if (memMB > THRESHOLD) {
        process.chdir('/path/to/writeable/dir');
        heapdump.writeSnapshot();
    }
}, 60000 * 5);
MEMORY MONITORING
Caution: Taking a heap snapshot is not trivial on
resources.
If you already have a memory problem, this could kill your
process!
Unfortunately sometimes you have no alternative.
SMART PROFILING
How can we using the monitoring to profile?
"smart profiling" based on event loop blockage
~$ slc ctl cpu­start 1.1.49408 20
1. Monitors a specific worker (1.1.49408)
2. Event loop blocked for more than 20ms, start CPU profile
3. Stop profiling once event loop resumes
FINDING THE WORKER ID
~$ slc ctl status
Service ID: 1
Service Name: my­app
Environment variables:
  No environment variables defined
Instances:
    Version  Agent version  Cluster size
     4.1.0       1.5.1            4
Processes:
        ID      PID   WID  Listening Ports  Tracking objects?  CPU profilin
    1.1.49401  49401   0
    1.1.49408  49408   1     0.0.0.0:3001
    1.1.49409  49409   2     0.0.0.0:3001
    1.1.49410  49410   3     0.0.0.0:3001
    1.1.49411  49411   4     0.0.0.0:3001
TRANSACTION TRACING
DEEP TRANSACTIN TRACING
Analyze performance of your application from a high level
down to the function level.
RESOURCE CONSUMPTION TIMELINE
ANOMOLY INSPECTION
See something off?
Click on that point in the resource usage chart.
(The orange triangles at the bottom identify anomolies
betond three-sigma deviations.)
VIEW TRACE SEQUENCES
TRACING WATERFALL
By clicking on the "sync" line we can inspect the costs of the
synchronous code.
FLAME CHARTS
FLAME CHARTS
The flame chart identifies each function in the call stack,
organized in color by module.
The size of the bar represents the total resource
consumption for that function and all of its function calls.
Clicking on a function shows that functions resource usage.
LOOKING FOR MORE?
Check out our blog post on Transaction Tracing and
identifying a DoS attack!
http://bit.ly/arc-tracing
THANK YOU!
QUESTIONS?
Jordan Kasper | Developer Evangelist
Join us for more events!
strongloop.com/developers/events

Contenu connexe

Dernier

A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 

Dernier (20)

A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 

En vedette

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

En vedette (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Node.js Transaction Tracing & Root Cause Analysis with StrongLoop Arc

  • 1. TRANSACTION TRACING & ROOT CAUSE ANALYSIS WITH STRONGLOOP ARC Jordan Kasper | Developer Evangelist
  • 2. STEP ONE The first step in monitoring, profiling, and tracing your Node application is to run it in a process manager!
  • 3. BUILD YOUR APP WITH SLC ~$ npm install ­g strongloop ~/my­app$ slc build ... ~/my­app$ ls ... ...  my­app­0.1.0.tgz
  • 4. INSTALL AND RUN STRONG PM On your deployment machine... ~$ npm install ­g strong­pm ~$ sl­pm­install
  • 5. DEPLOY TO STRONG PM From our development machine (or staging, etc)... ~/my­app$ slc deploy http+ssh://myserver.com:8701
  • 6. RUNNING LOCALLY If you need to profile things locally (your machine or a staging/testing server), run slc start from your app directory: ~/my­app$ slc start Process Manager is attempting to run app `.`.   To confirm it is started: slc ctl status tracing­example­app   To view the last logs: slc ctl log­dump tracing­example­app   ... Then start the Arc UI: ~/my­app$ slc arc
  • 7.
  • 10. AVAILABLE METRICS CPU Load (system) Heap Memory sage Event Loop Count Event Loop Tick Timing HTTP Connections Database Connections (Oracle, MySQL, Mongo, Postgres) Misc other modules (Redis, Memcache(d), Message queues)
  • 11. WHAT DO I LOOK FOR? CPU Usage is pretty obvious, just watach your high points! With Heap Memory Usage you want to see a "sawtooth" chart, each drop indicates garbage collection. No drop is bad!
  • 12. WHAT DO I LOOK FOR?
  • 13. WHAT DO I LOOK FOR? The two Event Loop metrics are opposed. You want the loop count to remain high under normal load (more ticks per metrics cycle is good). Any dips may be bad. The Loop timing, on the other hand, indicates how long event loop ticks are taking. Any spikes here are bad!
  • 14. SETUP METRICS COLLECTION On our production machine, with strong-pm installed, simply set the collection location: ~$ export STRONGLOOP_METRICS="log:/path/to/api­metrics.log" ~$ export STRONGLOOP_METRICS="syslog" ~$ export STRONGLOOP_METRICS="statsd://my­log­server.com:1234" ~$ export STRONGLOOP_METRICS="graphite://my­log­server.com:1234" ~$ export STRONGLOOP_METRICS="splunk://my­log­server.com:1234"
  • 15. SETUP METRICS COLLECTION Alternatively, on the production machine you can run: ~$ sl­pm­install ­­metrics <url> Or during runtime: ~$ slc ctl env­set my­app STRONGLOOP_METRICS=<url>
  • 17. PROFILING We can spot issues using the metrics being monitored, but now we need to find the cause of those issues. Profiling CPU usage and memory is the way to do this.
  • 21. PROGRAMMATIC MEMORY MONITORING If we have memory issues, it may be helpful to monitor memory usage dynamically. ~$ npm install heapdump ­­save var heapdump = require('heapdump'); var THRESHOLD = 500; setInterval(function () {     var memMB = process.memoryUsage().rss / 1048576;     if (memMB > THRESHOLD) {         process.chdir('/path/to/writeable/dir');         heapdump.writeSnapshot();     } }, 60000 * 5);
  • 22. MEMORY MONITORING Caution: Taking a heap snapshot is not trivial on resources. If you already have a memory problem, this could kill your process! Unfortunately sometimes you have no alternative.
  • 23. SMART PROFILING How can we using the monitoring to profile? "smart profiling" based on event loop blockage ~$ slc ctl cpu­start 1.1.49408 20 1. Monitors a specific worker (1.1.49408) 2. Event loop blocked for more than 20ms, start CPU profile 3. Stop profiling once event loop resumes
  • 24. FINDING THE WORKER ID ~$ slc ctl status Service ID: 1 Service Name: my­app Environment variables:   No environment variables defined Instances:     Version  Agent version  Cluster size      4.1.0       1.5.1            4 Processes:         ID      PID   WID  Listening Ports  Tracking objects?  CPU profilin     1.1.49401  49401   0     1.1.49408  49408   1     0.0.0.0:3001     1.1.49409  49409   2     0.0.0.0:3001     1.1.49410  49410   3     0.0.0.0:3001     1.1.49411  49411   4     0.0.0.0:3001
  • 26. DEEP TRANSACTIN TRACING Analyze performance of your application from a high level down to the function level.
  • 28. ANOMOLY INSPECTION See something off? Click on that point in the resource usage chart. (The orange triangles at the bottom identify anomolies betond three-sigma deviations.)
  • 30. TRACING WATERFALL By clicking on the "sync" line we can inspect the costs of the synchronous code.
  • 32. FLAME CHARTS The flame chart identifies each function in the call stack, organized in color by module. The size of the bar represents the total resource consumption for that function and all of its function calls. Clicking on a function shows that functions resource usage.
  • 33. LOOKING FOR MORE? Check out our blog post on Transaction Tracing and identifying a DoS attack! http://bit.ly/arc-tracing
  • 34. THANK YOU! QUESTIONS? Jordan Kasper | Developer Evangelist Join us for more events! strongloop.com/developers/events