SlideShare a Scribd company logo
Observable
Applications w/ Node.js
Yunong Xiao, Senior Node.js Engineer,
UI Platform, Netflix
@yunongx, yunong@netflix.com
March 2015
BayNode
The Bay Area Node.js Meetup
Node.js @
Netflix
• Website www.netflix.com
• Discovery
• Playback
• Acquisition
• Account Management
• Internal Services
• TV/Mobile/Devices
What’s Wrong?
Increased Errors Increased Latency
Memory Leak
What Now?
“It is a capital mistake to
theorize before one has DATA.
Insensibly one begins to twist
facts to suit theories, instead of
theories to suit facts.”
Sherlock Holmes
-A Scandal in Bohemia
Data Data Data
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Node.js Modules
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
vasync
• https://github.com/davepacheco/node-vasync
• Similar to caolan/async.
• Added observability.
async f() state
failed f()
successful f()
pending f()
finished f()
# of errors
vasync
• Make API requests.
• Persist state to file system.
• Query database.
• Update caches.
Async workflow management is error prone
Example
cb() not invoked
Results
function three pending
How Do I See this in Prod?
• Logs
• Core Dumps
• REPL
• HTTP API
node-bunyan
• https://github.com/trentm/node-bunyan
• Streaming JSON logging library for JS. (node
and browser)
Streaming JSON
• One JSON object per line. e.g. Twitter’s
streaming API.
• Perfect for machine processing. i.e. works with
Unix tools such as grep(1), cut(1), …
• Illegible for Humans
Streaming JSON
bunyan(1) CLI
Features
• Lightweight API
• Log levels: trace, debug, info, warn, error, fatal
• Extensible Streams interface.
• Custom object rendering with serializers.
• DTrace support.
Demo
DTrace
• Dynamic tracing framework.
• Available on Mac OS X (dev env). `man dtrace`
• Node.js DTrace USDT provider: https://
github.com/chrisa/node-dtrace-provider
• Pure JS probes.
bunyan -p
Demo
Production Tracing
• Production environment is Ubuntu Linux on EC2.
• Future work: get probe access. Possibilities:
• SystemTap
• LTTng (Linux Tracing Toolkit Next Gen)
• perf_events markers (currently a proposed
patch)
restify
• http://restifyjs.com
• Production tested REST framework.
• Observability.
• Metrics.
• First class Bunyan integration.
• DTrace.
Vanilla App
Vanilla App
Logging
Request Capture Stream
• Tradeoffs, Perf vs Verbosity.
• Captures all log statements including trace in
memory.
• Dump all logs only on error.
Audit Logs
Audit Logsstatus code request ID (UUID)
URL
request headers
response headers
individual handler timers
req latency
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Scoped Child Loggers
Logging
• Native Bunyan integration.
• Request capture stream.
• Audit logs with each req.
• Scoped child loggers with each req.
restify + Bunyan
• Streaming JSON.
• Processing using Unix tools is easy.
• Helpful tools:
• Unix: cut(1), wc(1), grep(1), awk(1), perl(1), …
• JSON: https://github.com/trentm/json (npm install -g
json)
• daggr: https://github.com/joyent/daggr (npm install -g
daggr)
Examples
• Find all logs for a specific request.
• Count the # of non-200 responses.
• Show all requests that took longer than 200ms.
Advanced Example
Request latency distribution by URL
DTrace
Demo
distributed
processing
• elasticsearch
• spark
• hive
bunyanrestify
audit logs
req id req headers
req latency
handler
latencies
URL
res codeErrors
res headers
Processing
w/ Unix tools
• grep(1)
• awk(1)
• cut(1)
• wc(1)
• sort(1)
• json(1)
• bunyan(1)
• …
req scoped logs
application specific
context
req capture stream
dumps all logs on error
DTrace*
req latency
handler
latencies
* Where available
restify metrics
Increased Errors Increased Latency
restify
Interested? Call for contributors.
restifyjs.com
The Killer Combo
• vasync: https://github.com/davepacheco/node-vasync
• Observable async operations.
• bunyan: https://github.com/trentm/node-bunyan
• Streaming JSON logs.
• restify: restifyjs.com
• Observable REST applications.
• Unix Tools
• Stream of text model. Many tools to manipulate JSON logs.
Data Data Data
Thanks
• Questions?
• yunong@netflix.com
• @yunongx
• http://restifyjs.com
March 2015
BayNode
The Bay Area Node.js Meetup

More Related Content

PDF
Node Interactive Debugging Node.js In Production
PDF
Debugging node in prod
PDF
Going FaaSter, Functions as a Service at Netflix
PDF
[231] the simplicity of cluster apps with circuit
PDF
Ignacy Kowalczyk
PPTX
Rapid Application Design in Financial Services
PDF
Kernel Recipes 2017: Using Linux perf at Netflix
PDF
DCSF 19 eBPF Superpowers
Node Interactive Debugging Node.js In Production
Debugging node in prod
Going FaaSter, Functions as a Service at Netflix
[231] the simplicity of cluster apps with circuit
Ignacy Kowalczyk
Rapid Application Design in Financial Services
Kernel Recipes 2017: Using Linux perf at Netflix
DCSF 19 eBPF Superpowers

What's hot (20)

PDF
Golang Performance : microbenchmarks, profilers, and a war story
PPTX
How go makes us faster (May 2015)
PDF
Kubernetes DNS Horror Stories
PDF
How to stay sane during your Vagrant journey
PDF
(Re)discover your AEM
PDF
Large-scaled Deploy Over 100 Servers in 3 Minutes
PDF
Performance Analysis Tools for Linux Kernel
PDF
Regex Considered Harmful: Use Rosie Pattern Language Instead
PDF
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
PDF
NBIS RNA-seq course
PDF
Extending Kubernetes – Admission webhooks
PDF
Perl Dist::Surveyor 2011
PDF
10 ways to shoot yourself in the foot with kubernetes, #9 will surprise you! ...
PDF
LISA17 Container Performance Analysis
PDF
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
PDF
Netflix: From Clouds to Roots
PDF
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
PDF
Into The Box 2018 Going live with commandbox and docker
PPTX
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
PDF
Making the most out of kubernetes audit logs
Golang Performance : microbenchmarks, profilers, and a war story
How go makes us faster (May 2015)
Kubernetes DNS Horror Stories
How to stay sane during your Vagrant journey
(Re)discover your AEM
Large-scaled Deploy Over 100 Servers in 3 Minutes
Performance Analysis Tools for Linux Kernel
Regex Considered Harmful: Use Rosie Pattern Language Instead
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
NBIS RNA-seq course
Extending Kubernetes – Admission webhooks
Perl Dist::Surveyor 2011
10 ways to shoot yourself in the foot with kubernetes, #9 will surprise you! ...
LISA17 Container Performance Analysis
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
Netflix: From Clouds to Roots
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
Into The Box 2018 Going live with commandbox and docker
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Making the most out of kubernetes audit logs
Ad

Similar to Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014 (20)

PDF
Observable Node.js Applications - EnterpriseJS
PDF
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
PDF
Node.js for beginner
PPTX
Quick look in Reactive Extensions
PPTX
Tuenti Release Workflow
PPTX
introduction to node.js
PPTX
Be faster then rabbits
KEY
Firefox Crash Reporting (@ Open Source Bridge)
PPT
Node and Azure
PPTX
Node.JS and WebSockets with Faye
PPTX
System insight without Interference
PDF
Web a Quebec - JS Debugging
PDF
Web_of_Things_2013
KEY
20120306 dublin js
PPTX
Getting started with Office 365 SharePoint 2010 online development
PDF
What we do with Go
PDF
Streams API (Web Engines Hackfest 2015)
PPTX
Webdevcon Keynote hh-2012-09-18
PDF
Afs manager
Observable Node.js Applications - EnterpriseJS
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
Node.js for beginner
Quick look in Reactive Extensions
Tuenti Release Workflow
introduction to node.js
Be faster then rabbits
Firefox Crash Reporting (@ Open Source Bridge)
Node and Azure
Node.JS and WebSockets with Faye
System insight without Interference
Web a Quebec - JS Debugging
Web_of_Things_2013
20120306 dublin js
Getting started with Office 365 SharePoint 2010 online development
What we do with Go
Streams API (Web Engines Hackfest 2015)
Webdevcon Keynote hh-2012-09-18
Afs manager
Ad

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPT
Teaching material agriculture food technology
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Approach and Philosophy of On baking technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Modernizing your data center with Dell and AMD
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
KodekX | Application Modernization Development
PDF
cuic standard and advanced reporting.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Understanding_Digital_Forensics_Presentation.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Teaching material agriculture food technology
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Unlocking AI with Model Context Protocol (MCP)
Approach and Philosophy of On baking technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Diabetes mellitus diagnosis method based random forest with bat algorithm
Modernizing your data center with Dell and AMD
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
KodekX | Application Modernization Development
cuic standard and advanced reporting.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Big Data Technologies - Introduction.pptx
Machine learning based COVID-19 study performance prediction
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing

Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014