SlideShare uma empresa Scribd logo
1 de 20
© 2016 Dynatrace
Feelingthe love
for Node.js
The performancebasicsyou needto know now
Table of contents
Executive summary
Feeling the love for Node.js
© 2016 Dynatrace
1
Why enterprises loveNode.js 2
The Node.js buildingblocks 8
Performance and Node.js 12
Additional resources 17
Back to Table ofContents
Feeling the love for Node.js
© 2016 Dynatrace
1
Executive summary
Node.js is not just new technology for the start-ups
anymore. Enterprises of all types are beginning to use
Node.js. But why?
> Functionality that is pragmatic and smart, offering basic building blocks instead
of wizardry and black box functionality designed by framework developers.
> Program execution that doesn’t stop and wait when performing I/O requests,
which saves system resources and provides a better overall performance.
> Technology that bridges existing systems and new technologies and provides an
easily deployable migration layer that either proxies data to existing systems or
collects and reformats it for different uses.
While Node.js has a lot of benefits, including a flat learning curve, the machinery that
keeps it ticking is complex. You must understand it to avoid performance pitfalls.
In this eBook, we will discuss the basic building blocks of Node.js and how memory
works for Node, including garbage collection. We will also give you some tips on how to
hunt down memory leaks, CPU issues, and other problems to improve performance.
© 2016 Dynatrace
Chapter1
Why enterprisesloveNode.js
Back to Table ofContents
Google searches and jobs
Feeling the love for Node.js
© 2016 Dynatrace
3
Seasoned developers know that every few months there is
a new game-changing technology that passes into oblivion.
This is not the case with Node.js.
Google Trends shows search traffic by keyword over time, and is a great way to identify
the relevance of a given topic, especially when correlated with other terms. When you
compare search traffic on Node.js to Ruby on Rails, you can clearly see that Node.js
gained momentum after its introduction in 2009 and now has beaten its competitor.
Another indicator of relevance is Indeed Job Trends. If you compare job growth to
other related technologies, you see Node.js again comes out ahead.
Alert readers may argue that the charts looked
the same for technologies like Ruby on Rails some
years back. So how’s Node.js different?
Big established companies
with years of legacy software
arenow shifting to Node.js.
Back to Table ofContents
Every new kid on the
technology block gains
momentum in the beginning,
especially because startups
tend to use the freshest
technologies.
But big established companies with
years of legacy software are now shifting
to Node.js – Walmart, eBay, PayPal,
Microsoft, The New York Times, Dow Jones,
etc. The list goes on.
It’s uncommon for enterprises to adopt
a technology like this so early in its hype
cycle. We need to peek into howNode.js
works to understand the reasons.
What the big brands say
“Node’s evented I/O model freed us from worrying
about locking and concurrency issues that are
common with multithreaded async I/O.”
-Subbu Allarmarju,
Principal Member, Technical Staff at ebay
“On the server side, our entire
mobile software stack is completely
built in Node. One reason was
scale. The second is Node showed
us huge performance gains.”
-Kiran Prasad,
Mobile Development Lead at LinkedIn
“Node.js powers our web applications andhas
allowed our teams to move much faster in
bringing their designs to life.”
-Jeff Harrell,
Director of Engineering at PayPal
Feeling the love for Node.js
© 2016 Dynatrace
4
Back to Table ofContents
For so many years, the trend has been toward framework
and wizardry.
Just enter some commands in the shell you get a full-fledged ORM layer out of
your database scheme. Apparently, it seemed like a good idea to abstract as much
logic as possible away from the developer and offer some easy-to-use interface for
functionality that framework developers think is useful.
You know those “build your own blog in five minutes” examples. Everything looks easy
and great until you try to implement real requirements for real clients.
It’s tempting to take the easy road and rely on generators and out-of-the-box
features, but this never works out. The time you save will be spent trying to figure
out why the ORM layer logic hidden deep inside the framework doesn’t let you
do a select on a date range. Instead of building from your own code, you end
up spending your time reading through documents, Googling, and posting on
StackOverflow just to understand code written by someone else.
Black magic wizadry
Feeling the love for Node.js
© 2016 Dynatrace
5
Back to Table ofContents
Node.js is a framework
based on JavaScript that
uses Google’s V8 engine.
It adds functionality in a very pragmatic
and smart way by offering only the basic
building blocks, like file system access,
protocol support, and cryptology along
with some basic utility functions.
Also of note, JavaScript supports event
based programming — just look atthe
OnClick() in browser environments —
and has functions as first class
members. This makes it a perfect fit
for event-callback constructs that
are a cornerstone of asynchronous
programming. In short, this means that
program execution doesn’t stop and
wait when performing I/O requests,
which saves system resources and
provides better performance.
Back to craftsmanship
"Reading Node.js docs feels like Zen:
reduced,focused, and concise. It feels
like getting back to the essence of
programming again. Nobells,
no whistles.”
– Daniel Khan,
Technology Strategist,Dynatrace
Feeling the love for Node.js
© 2016 Dynatrace
6
Enterprise grade LTSis another reason to love Node.js
Anew Long Term Support model was introduced in the Fall,2015.
Long-term support (LTS) releases will now be actively developed for 18 months
and maintained for another 12 months. So a LTS release may effectively stay in
production for 30 (!) months, while still receiving bug and security fixes.
For even more enterprise features and support, you can look up N|Solid.
Back to Table ofContents
During the last few years,the
requirements for network-
connected software systems
changed dramatically.
> Responsive, dynamic sites replaced
static or semi-static websites for
desktop computers.
> Sites started to load additional
content via Ajax/XHR or even rely on
push technologies like WebSockets.
> Streaming services began to rise
in popularity.
> Data of all kinds now needs to be
delivered to an ever-growing number
of users, with different devices in
different formats.
These changing and growing
requirements can either be fulfilled by
adding new hardware and extending
existing software or by adding a new
layer that uses existing infrastructure
more efficiently and supports the
new technologies.
That's where Node.js shines — with
modern, web-connected applications
that need to gather data from different
sources, consolidate it, and push it to
many clients in real-time. It is theperfect
bridging technology for existing systems
because it provides an easily deployable
migration layer that either proxies data
to existing systems or collects and
reformats data for different uses.
The Node.js bridge
MySQ
L
M
ORACL
E
M
Feeling the love for Node.js
© 2016 Dynatrace
7
© 2016 Dynatrace
Chapter2
TheNode.jsbuilding
blocks
Back to Table ofContents
It can be a daunting task
to implement a full-
fledged web server when
all you have is the basic
HTTP commands.
But not relying on complexframeworks
does not mean that you have to build
everything from scratch.
Modules are an important building
block for Node.js and expose
functionality by the global data
structure, module.exports.
Modules are included and assigned to
a variable with require(). The exported
functionality is only accessible through
this variable, which means that every
module creates a namespace.
The great thing about Node.js is that the
Npm — the Node Package Manager, a
collection of modules, currently holds
more than 140,000 (!) packages for
various purposes, and most of themare
maintained on GitHub.
Many of them adhere to the “Do one
thing and do it well” philosophy known
from UNIX. The result is a pool of small
bits of functionality that can be mixed
and composed as needed. There are
also a few larger packages that provide
a set of functionality, with express
being the most popular — it provides
http, routing, and template rendering
functions that most web projectsneed.
If you ever had to migrate a complex
legacy php application to a new server,
you know that this can getextremely
unpleasant due to the globally installed
extensions and libraries required. Thisis
not the case with Node.js.
In Node.js, all dependencies are
registered in package.js and installed
into the projects directory structure.
Spinning up a new instance running
an application only takes minutes
with Node.js because there are no
dependencies to the environment
(except the node binary) and no need
for a specific server environment.
This makes Node.js the platform
of choice for projects following the
Immutable Infrastructure principle
introduced by Chad Fowler in 2013.
Modules, packages, and
immutable infrastructure
Gettingstarted
On Linux use your package manager to
install the latest nodejs package. For all
other operating systems, download the
binaries from the Node.jswebsite.
Feeling the love for Node.js
© 2016 Dynatrace
9
Then run Node.js applications by typing
node <yourapplication.js>.
Here’s a basic “Hello world” example. Run
it and open http://localhost:4242 in your
browser to see if everything isworking.
Back to Table ofContents
Memory in Node.js means Google V8
While Node.js has a rather
flat learning curve, the
machinery that keeps it
ticking is quite complex.
You must understand it to avoid
performance pitfalls. Unlike platforms
like PHP,Node.js applications are long-
running processes. While this has a lot
of positive implications such as allowing
database connections to be set uponce
and then reused for all requests, this
may also cause problems.
Node.js is a C++program controlled via
V8 JavaScript. Google V8 is a JavaScript
engine initially created for Google
Chrome, but it can also be used as a
standalone. This makes it the perfect fit
for Node.js. V8 compiles JavaScript down
to native code and executes it, and
manages memory allocation.
Arunning program is always
represented through some space
allocated in memory, the Resident Set.
V8 uses a scheme similar to the Java
Virtual Machine and divides the memory
into segments.
> Code: the actual code beingexecuted.
> Stack: contains all value types
(primitives like integer or Boolean)
with pointers referencing objects on
the heap and pointers defining the
control flow of the program.
> Heap: a memory segment dedicated
to storing reference types likeobjects,
strings, and closures.
Within Node.js, current memory usage
can easily be queried by calling process.
memoryUsage().This function will returnan
object containing: Resident Set Size, Total
Sizeof theHeap, Heap Used. Youcan use
this function to record the memory usage
over time in a heap graph.
The heap graph is highly volatile, but
always stays within certain boundaries
to keep the median consumption
constant. The mechanism that allocates
and frees heap memory is called
garbage collection.
Feeling the love for Node.js
© 2016 Dynatrace
10
Back to Table ofContents
Understanding garbage collection
Every program that
consumes memory requires
a mechanism for reserving
and freeing space.
If a program allocates memory that is
never freed, the heap will constantly
grow, creating a memory leak, until the
usable memory is exhausted causingthe
program tocrash.
Because Node.js JavaScriptis compiled
to native code by V8, the resulting native
data structures don’t have much to do
with their original representation and are
solely managed by V8. This means that
we cannot actively allocate or de-allocate
memory in JavaScript. V8 uses garbage
collection to address thisproblem.
The theory behind garbage collection
is simple: if a memory segment is not
referenced from anywhere, wecan
assume that it is notused and therefore,
it can be freed. However,retrieving
and maintaining this information is
complex because there may be chained
references and indirections that form a
complex graph structure.
Garbage collection is a costly process
because it interrupts the execution
of an application and impacts its
performance. Toremedy this situation,
V8 uses two types of garbagecollection:
> Scavenge — fast, but incomplete
> Mark-Sweep — relatively slow, but
frees all non-referenced memory
Revisiting the data collected from
process.memoryUsage() and the chart
on the previous page, you canidentify
the different garbage collection types:
the saw-tooth pattern is createdby
Scavenge runs and the downward jumps
indicate Mark-Sweep operations.
By using the native module, node-gc-
profiler, you can gather even more
information about garbage collection
runs. The module subscribes to garbage
collection events fired by V8, and
exposes them to JavaScript. The object
returned indicates the type of garbage
collection and the duration.
Feeling the love for Node.js
© 2016 Dynatrace
11
© 2016 Dynatrace
Chapter3
Node.jsandperformance
Back to Table ofContents
Feeling the love for Node.js
© 2016 Dynatrace
13
Hunting downmemory leaks
So if garbage collection
cleans up the memory, why
do you have to care at all?In
fact, it is still possible —and
easy —for memory leaks to
suddenly appear in your logs.
Garbage collection tries its best to free
memory, but on the chart (right), we
see that consumption after a garbage
collection run is constantly climbing, a
clear indication of aleak.
Some causes of leaks are obvious —
if you store data in process-global
variables, like the IPof every visiting
user in an array. Others are subtler like
the famous Walmart memory leak that
was caused by a tiny missing statement
within Node.js core code, and which
took weeks to track down.
V8 provides a way to dump the current
heap, and the V8-profiler exposes
this functionality to JavaScript.Here is
the code to do this. There are more
sophisticated approaches to detect
anomalies, but this is a good place
to start.
If there is a memory leak, you may
end up with a significant number
of heap dump files. So you should
monitor this closely and add some
alerting capabilities to that module.The
same heap dump functionality is also
provided within Chrome, and you can
use Chrome developer tools to analyze
the dump’s V8-profiler.
One heap dump may not help you,
however, because it won’t show youhow
the heap develops over time. That’s why
Chrome developer tools allow you to
compare different memory profiles.
By comparing two dumps, you get delta
values that indicate which structures
grew between two dumps.
Back to Table ofContents
The Node.js single thread and CPUissues
The statement ‘Node.js runs
in a single thread’ is only
partly true.
If you start up a simple applicationand
look at the processes, you see that
Node.js, in fact, spins up anumber
of threads. This is because Node.js
maintains a thread pool to delegate
synchronous tasks to, while GoogleV8
creates its own threads for tasks like
garbage collection.
Node.js uses libuv, which provides
the thread pool and an event loop to
achieve asynchronous I/O.
Reading a file is a synchronous input
output task and can take its time. In
synchronous programming, the thread
runningreadfile() would now pause
and wait until the system callreturns
the contents of the file. That’s why,
for client-server environments (like
web applications), most platforms will
create one thread per request. APHP
application, within Apache using
mod_php, works exactly like that.
The “single-threaded” Node.js works
differently. To not block the main thread,
it delegates the readfile() task tolibuv.
Libuv will then push the callback function
to a queue and use some rules to
determine how the task will be executed.
In some cases, it will now use the thread
pool to load off the work, but it may also
create asynchronous tasks to behandled
directly by theoperating system.
The event loop continuously runs over
the callback queue and will execute a
callback, if the associated task hasbeen
finished. The execution of the callback
— and this is very important —will
again run on the mainthread.
Usually this works just fine, but there
will be a problem if someone decides
to perform a CPUconsuming operation
like calculating some prime numbers
inside the callback. This will block the
main thread, prevent new requests
from being processed and cause the
application to slowdown.
Feeling the love for Node.js
© 2016 Dynatrace
14
Back to Table ofContents
Mind your environment (aka NODE_ENV)
Most developers learn best by examples, which naturally
tend to simplify matters and omit things that aren’tessential
for understanding.
This means that the “Hello World” example on Page7,when used as starting point
for an application, may be not suitable forproduction scenarios.
Environment variables are often used for distinguishing between production or
development. Depending on those variables an application may turn debugging
on or off, connect to a specific database, or listen on a specific port. In Node.js,
NODE_ENV is used to set the current mode.
If you use Express.js and install the template engine without setting NODE_ENV, it will
default to development. It will switch the view cache on, which makes sense. You don’t
want to restart your app to clear the cache every time you change some markup.
This means your views are parsed and rendered for every request in development
mode. The question is whether this causes a notable performance hit.
It does. Setting NODE_ENV to production makes the application three times faster.
NODE_ENV works like any other environment variable
(e.g. Setting NODE_ENV PATH) and setting it depends on your platform.
Linux and OSX:
export NODE _ ENV=production
Windows:
SET NODE _ ENV=production
On all platforms, you can explicitly
set it when starting your application
like this: NODE_ENV=production node
myapp.js. You may also use a module
like dotenv to set it from an .env file
in your application directory. You
should avoid setting the environment
directly in your codebecause
this contradicts the purposeof
environment variables.
Feeling the love for Node.js
© 2016 Dynatrace
15
CPU sampling and
sunbursts
Totrace down CPUheavy
operations, you need a way
to introspect on what’s
happening on the CPUin a
given time period.
This introspection is called CPU sampling
and luckily Google V8, the engine that
compiles and executes JavaScriptin
Node.js, provides a CPUsampling
interface. That can be accessed from
JavaScriptusing the module v8-profiler.
This is the code you need to run the
CPU profiler for five seconds every 30
seconds, and then store the sampling
data under a timestamp-based
filename. The file has a JSON tree
structure, and there are a several ways
to analyzeit.
> Google Chrome ships with a set of
developer tools useful for profiling
and debugging JavaScript on websites.
For a CPUintensive task, you can
sort the call treeby heaviness — how
much CPUtime it used in theperiod
— and quickly identify the issue.This
approach works when there is an
issue with a singlefunction.
> When the problem is more
complicated, Flame charts provide an
eye-friendly visualization that presents
the whole call stack. Here’s a story
by Netflix on how they used them to
trace down a bug in their application.
> Another option, Sunburst charts do a
particular good job of visualizing CPU
problems.
In Sunburst charts, the blue center is
the main function. Everyfunction called
directly from main is placedin the adjacent
row of the chart. If a function calls another
function, it will be placed into an adjacent
segment to the callingfunction.
One circle segment spans all its children
and the distance from the center is the
depth of a function within the call tree.
The angle measure represents the time
a function and its children spent on the
CPUwith 365° being 100% of the time.
Toactually create one of these awesome
charts, you can use D3.js, a popular
and very powerful data visualization
framework written in JavaScript. There
are many code examples to show
function name on a hover. You can see a
full script here.
Click here to open the
chart in your browser and
hover over thesegments to
display the function names.
Feeling the love for Node.js
© 2016 Dynatrace
16
Back to Table ofContents
Back to Table ofContents
Additional resources
With Node.js, you, can gather debugging performance data via JavaScript using
v8-profiler, and analyze the data in visualization tools like D3.js. For small, single tier
applications this can provide a minimal viable monitoring solution.
Tosee the big picture for more complex applications, however, you need a complete
performance monitoring solution. It should allow you to monitor thefull Node.js
stack — everything from V8 memory analysis to drill-down intodatabase queries,
code-level error diagnosis, user experience monitoring, outbound calls to external
services and APIs,and server/infrastructure health analysis.
Wehope this book has given you some insight on how enterprises are using
Node.js and some tips on how to pinpoint performance problems. To the right are
some additional resources on Node.js and performance monitoring in general.
Yourhomework
Videos
> Walmart Node.js memory leak
The blogroll
> About: Performance
> Joyent Blog on Walmart Node.js memory leak
> The NewStack
> The Netflix Tech Blog
> #monitoringlife
Recommended reading
> Chetan Desai @Intuit
> NodeSchool
> 7 performance metrics to release better software, faster
> DevOps hidden risks and how to achieve results
Feeling the love for Node.js
© 2016 Dynatrace
17
Learn more atdynatrace.com
Dynatrace is the innovator behind the industry’s premierDigital Performance Platform,makingreal-time information about digital performance visible and actionable for everyone across business and IT. We helpcustomers of all sizes see their applications and digital channels through
the lens of their end users. More than 7,500organizations use these insights tomaster complexity, gain operational agility and grow revenue bydeliveringamazing customer experiences.
4.8.16 589_SS_Nodejs_jg

Mais conteúdo relacionado

Destaque

How to Troubleshoot & Optimize Database Query Performance for Your Application
How to Troubleshoot  & Optimize Database Query Performance for Your ApplicationHow to Troubleshoot  & Optimize Database Query Performance for Your Application
How to Troubleshoot & Optimize Database Query Performance for Your ApplicationDynatrace
 
Infrastructure Automation How to Use Chef For DevOps Success
Infrastructure Automation How to Use Chef For DevOps SuccessInfrastructure Automation How to Use Chef For DevOps Success
Infrastructure Automation How to Use Chef For DevOps SuccessDynatrace
 
6 ways DevOps helped PrepSportswear move from monolith to microservices
6 ways DevOps helped PrepSportswear move from monolith to microservices6 ways DevOps helped PrepSportswear move from monolith to microservices
6 ways DevOps helped PrepSportswear move from monolith to microservicesDynatrace
 
Why Everyone Needs DevOps Now - Gene Kim
Why Everyone Needs DevOps Now - Gene KimWhy Everyone Needs DevOps Now - Gene Kim
Why Everyone Needs DevOps Now - Gene KimDynatrace
 
From 0 to DevOps in 80 Days [Webinar Replay]
From 0 to DevOps in 80 Days [Webinar Replay]From 0 to DevOps in 80 Days [Webinar Replay]
From 0 to DevOps in 80 Days [Webinar Replay]Dynatrace
 
Metrics-Driven Devops: Delivering High Quality Software Faster!
Metrics-Driven Devops: Delivering High Quality Software Faster! Metrics-Driven Devops: Delivering High Quality Software Faster!
Metrics-Driven Devops: Delivering High Quality Software Faster! Dynatrace
 
5 Steps to Building a Mature DevOps Organization with Sherwin-Williams
5 Steps to Building a Mature DevOps Organization with Sherwin-Williams5 Steps to Building a Mature DevOps Organization with Sherwin-Williams
5 Steps to Building a Mature DevOps Organization with Sherwin-WilliamsDynatrace
 
Sprinting for Success: Digital Transformation through Agile and DevOps
Sprinting for Success: Digital Transformation through Agile and DevOpsSprinting for Success: Digital Transformation through Agile and DevOps
Sprinting for Success: Digital Transformation through Agile and DevOpsDynatrace
 
Starting Your DevOps Journey – Practical Tips for Ops
Starting Your DevOps Journey – Practical Tips for OpsStarting Your DevOps Journey – Practical Tips for Ops
Starting Your DevOps Journey – Practical Tips for OpsDynatrace
 
Top Lessons Learned While Researching and Writing The DevOps Handbook
Top Lessons Learned While Researching and Writing The DevOps HandbookTop Lessons Learned While Researching and Writing The DevOps Handbook
Top Lessons Learned While Researching and Writing The DevOps HandbookDynatrace
 
Sitecore Digital Survivor Series - How Web and App Performance impacts Custom...
Sitecore Digital Survivor Series - How Web and App Performance impacts Custom...Sitecore Digital Survivor Series - How Web and App Performance impacts Custom...
Sitecore Digital Survivor Series - How Web and App Performance impacts Custom...Dynatrace
 
Accelerate User Driven Innovation [Webinar]
Accelerate User Driven Innovation [Webinar]Accelerate User Driven Innovation [Webinar]
Accelerate User Driven Innovation [Webinar]Dynatrace
 
Our DevOps Journey: 6 Month Waterfalls to 1 Hour Code Deploys
Our DevOps Journey: 6 Month Waterfalls to 1 Hour Code DeploysOur DevOps Journey: 6 Month Waterfalls to 1 Hour Code Deploys
Our DevOps Journey: 6 Month Waterfalls to 1 Hour Code DeploysDynatrace
 

Destaque (14)

How to Troubleshoot & Optimize Database Query Performance for Your Application
How to Troubleshoot  & Optimize Database Query Performance for Your ApplicationHow to Troubleshoot  & Optimize Database Query Performance for Your Application
How to Troubleshoot & Optimize Database Query Performance for Your Application
 
Infrastructure Automation How to Use Chef For DevOps Success
Infrastructure Automation How to Use Chef For DevOps SuccessInfrastructure Automation How to Use Chef For DevOps Success
Infrastructure Automation How to Use Chef For DevOps Success
 
6 ways DevOps helped PrepSportswear move from monolith to microservices
6 ways DevOps helped PrepSportswear move from monolith to microservices6 ways DevOps helped PrepSportswear move from monolith to microservices
6 ways DevOps helped PrepSportswear move from monolith to microservices
 
Why Everyone Needs DevOps Now - Gene Kim
Why Everyone Needs DevOps Now - Gene KimWhy Everyone Needs DevOps Now - Gene Kim
Why Everyone Needs DevOps Now - Gene Kim
 
From 0 to DevOps in 80 Days [Webinar Replay]
From 0 to DevOps in 80 Days [Webinar Replay]From 0 to DevOps in 80 Days [Webinar Replay]
From 0 to DevOps in 80 Days [Webinar Replay]
 
Metrics-Driven Devops: Delivering High Quality Software Faster!
Metrics-Driven Devops: Delivering High Quality Software Faster! Metrics-Driven Devops: Delivering High Quality Software Faster!
Metrics-Driven Devops: Delivering High Quality Software Faster!
 
5 Steps to Building a Mature DevOps Organization with Sherwin-Williams
5 Steps to Building a Mature DevOps Organization with Sherwin-Williams5 Steps to Building a Mature DevOps Organization with Sherwin-Williams
5 Steps to Building a Mature DevOps Organization with Sherwin-Williams
 
Sprinting for Success: Digital Transformation through Agile and DevOps
Sprinting for Success: Digital Transformation through Agile and DevOpsSprinting for Success: Digital Transformation through Agile and DevOps
Sprinting for Success: Digital Transformation through Agile and DevOps
 
Starting Your DevOps Journey – Practical Tips for Ops
Starting Your DevOps Journey – Practical Tips for OpsStarting Your DevOps Journey – Practical Tips for Ops
Starting Your DevOps Journey – Practical Tips for Ops
 
Top Lessons Learned While Researching and Writing The DevOps Handbook
Top Lessons Learned While Researching and Writing The DevOps HandbookTop Lessons Learned While Researching and Writing The DevOps Handbook
Top Lessons Learned While Researching and Writing The DevOps Handbook
 
Dyna trace
Dyna traceDyna trace
Dyna trace
 
Sitecore Digital Survivor Series - How Web and App Performance impacts Custom...
Sitecore Digital Survivor Series - How Web and App Performance impacts Custom...Sitecore Digital Survivor Series - How Web and App Performance impacts Custom...
Sitecore Digital Survivor Series - How Web and App Performance impacts Custom...
 
Accelerate User Driven Innovation [Webinar]
Accelerate User Driven Innovation [Webinar]Accelerate User Driven Innovation [Webinar]
Accelerate User Driven Innovation [Webinar]
 
Our DevOps Journey: 6 Month Waterfalls to 1 Hour Code Deploys
Our DevOps Journey: 6 Month Waterfalls to 1 Hour Code DeploysOur DevOps Journey: 6 Month Waterfalls to 1 Hour Code Deploys
Our DevOps Journey: 6 Month Waterfalls to 1 Hour Code Deploys
 

Mais de Dynatrace

Virgin Money: Virgin Money's quest for digital performance perfection
Virgin Money: Virgin Money's quest for digital performance perfectionVirgin Money: Virgin Money's quest for digital performance perfection
Virgin Money: Virgin Money's quest for digital performance perfectionDynatrace
 
Dynatrace: The untouchables - the Dynatrace offering here and now
Dynatrace: The untouchables - the Dynatrace offering here and nowDynatrace: The untouchables - the Dynatrace offering here and now
Dynatrace: The untouchables - the Dynatrace offering here and nowDynatrace
 
Starbucks: Building a new dev culture and freeing time for innovation: A Star...
Starbucks: Building a new dev culture and freeing time for innovation: A Star...Starbucks: Building a new dev culture and freeing time for innovation: A Star...
Starbucks: Building a new dev culture and freeing time for innovation: A Star...Dynatrace
 
SITA: How smart apps are making air travel easier, every step of the way
SITA: How smart apps are making air travel easier, every step of the waySITA: How smart apps are making air travel easier, every step of the way
SITA: How smart apps are making air travel easier, every step of the wayDynatrace
 
Red Hat: Self driving IT is here, and it's real
Red Hat: Self driving IT is here, and it's realRed Hat: Self driving IT is here, and it's real
Red Hat: Self driving IT is here, and it's realDynatrace
 
Paypal, Barbri: Lost in the cloud? Top challenges facing CIOs in a cloud nati...
Paypal, Barbri: Lost in the cloud? Top challenges facing CIOs in a cloud nati...Paypal, Barbri: Lost in the cloud? Top challenges facing CIOs in a cloud nati...
Paypal, Barbri: Lost in the cloud? Top challenges facing CIOs in a cloud nati...Dynatrace
 
Pivotal: Join us for a fireside chat with CEO of Pivotal
Pivotal: Join us for a fireside chat with CEO of PivotalPivotal: Join us for a fireside chat with CEO of Pivotal
Pivotal: Join us for a fireside chat with CEO of PivotalDynatrace
 
Harrods: Re-inventing the luxury retail market
Harrods: Re-inventing the luxury retail marketHarrods: Re-inventing the luxury retail market
Harrods: Re-inventing the luxury retail marketDynatrace
 
Dynatrace: Meet our captain of product and all things awesome, Steve Tack
Dynatrace: Meet our captain of product and all things awesome, Steve TackDynatrace: Meet our captain of product and all things awesome, Steve Tack
Dynatrace: Meet our captain of product and all things awesome, Steve TackDynatrace
 
Dynatrace: Accelerate your cloud innovation Welcome to Perform 2018
Dynatrace: Accelerate your cloud innovation Welcome to Perform 2018Dynatrace: Accelerate your cloud innovation Welcome to Perform 2018
Dynatrace: Accelerate your cloud innovation Welcome to Perform 2018Dynatrace
 
Dynatrace: Going beyond APM and soaring to the future
Dynatrace: Going beyond APM and soaring to the futureDynatrace: Going beyond APM and soaring to the future
Dynatrace: Going beyond APM and soaring to the futureDynatrace
 
Dynatrace: Davis - Hololens - AI update - Cloud announcements - Self driving IT
Dynatrace: Davis - Hololens - AI update - Cloud announcements - Self driving ITDynatrace: Davis - Hololens - AI update - Cloud announcements - Self driving IT
Dynatrace: Davis - Hololens - AI update - Cloud announcements - Self driving ITDynatrace
 
Altimeter Group: The new face of change
Altimeter Group: The new face of changeAltimeter Group: The new face of change
Altimeter Group: The new face of changeDynatrace
 
Alastair Humphreys: Life stories and inspiration from Alastair Humphreys
Alastair Humphreys: Life stories and inspiration from Alastair HumphreysAlastair Humphreys: Life stories and inspiration from Alastair Humphreys
Alastair Humphreys: Life stories and inspiration from Alastair HumphreysDynatrace
 
AWS: Serverless Architecture - Beyond functions and into the future
AWS: Serverless Architecture - Beyond functions and into the future AWS: Serverless Architecture - Beyond functions and into the future
AWS: Serverless Architecture - Beyond functions and into the future Dynatrace
 
Zurich: Monitoring a sales force-based insurance application using dynatrace ...
Zurich: Monitoring a sales force-based insurance application using dynatrace ...Zurich: Monitoring a sales force-based insurance application using dynatrace ...
Zurich: Monitoring a sales force-based insurance application using dynatrace ...Dynatrace
 
Sentry: Baselining, cloud-scale monitoring and auto-remediation with app mon ...
Sentry: Baselining, cloud-scale monitoring and auto-remediation with app mon ...Sentry: Baselining, cloud-scale monitoring and auto-remediation with app mon ...
Sentry: Baselining, cloud-scale monitoring and auto-remediation with app mon ...Dynatrace
 
SEI: Faster innovation and better performance for the innovative sei wealth p...
SEI: Faster innovation and better performance for the innovative sei wealth p...SEI: Faster innovation and better performance for the innovative sei wealth p...
SEI: Faster innovation and better performance for the innovative sei wealth p...Dynatrace
 
SAP: How SAP fully automates the provisioning and operations of its dynatrace...
SAP: How SAP fully automates the provisioning and operations of its dynatrace...SAP: How SAP fully automates the provisioning and operations of its dynatrace...
SAP: How SAP fully automates the provisioning and operations of its dynatrace...Dynatrace
 
REI: Evolving performance engineering for the move to cloud, microservices, c...
REI: Evolving performance engineering for the move to cloud, microservices, c...REI: Evolving performance engineering for the move to cloud, microservices, c...
REI: Evolving performance engineering for the move to cloud, microservices, c...Dynatrace
 

Mais de Dynatrace (20)

Virgin Money: Virgin Money's quest for digital performance perfection
Virgin Money: Virgin Money's quest for digital performance perfectionVirgin Money: Virgin Money's quest for digital performance perfection
Virgin Money: Virgin Money's quest for digital performance perfection
 
Dynatrace: The untouchables - the Dynatrace offering here and now
Dynatrace: The untouchables - the Dynatrace offering here and nowDynatrace: The untouchables - the Dynatrace offering here and now
Dynatrace: The untouchables - the Dynatrace offering here and now
 
Starbucks: Building a new dev culture and freeing time for innovation: A Star...
Starbucks: Building a new dev culture and freeing time for innovation: A Star...Starbucks: Building a new dev culture and freeing time for innovation: A Star...
Starbucks: Building a new dev culture and freeing time for innovation: A Star...
 
SITA: How smart apps are making air travel easier, every step of the way
SITA: How smart apps are making air travel easier, every step of the waySITA: How smart apps are making air travel easier, every step of the way
SITA: How smart apps are making air travel easier, every step of the way
 
Red Hat: Self driving IT is here, and it's real
Red Hat: Self driving IT is here, and it's realRed Hat: Self driving IT is here, and it's real
Red Hat: Self driving IT is here, and it's real
 
Paypal, Barbri: Lost in the cloud? Top challenges facing CIOs in a cloud nati...
Paypal, Barbri: Lost in the cloud? Top challenges facing CIOs in a cloud nati...Paypal, Barbri: Lost in the cloud? Top challenges facing CIOs in a cloud nati...
Paypal, Barbri: Lost in the cloud? Top challenges facing CIOs in a cloud nati...
 
Pivotal: Join us for a fireside chat with CEO of Pivotal
Pivotal: Join us for a fireside chat with CEO of PivotalPivotal: Join us for a fireside chat with CEO of Pivotal
Pivotal: Join us for a fireside chat with CEO of Pivotal
 
Harrods: Re-inventing the luxury retail market
Harrods: Re-inventing the luxury retail marketHarrods: Re-inventing the luxury retail market
Harrods: Re-inventing the luxury retail market
 
Dynatrace: Meet our captain of product and all things awesome, Steve Tack
Dynatrace: Meet our captain of product and all things awesome, Steve TackDynatrace: Meet our captain of product and all things awesome, Steve Tack
Dynatrace: Meet our captain of product and all things awesome, Steve Tack
 
Dynatrace: Accelerate your cloud innovation Welcome to Perform 2018
Dynatrace: Accelerate your cloud innovation Welcome to Perform 2018Dynatrace: Accelerate your cloud innovation Welcome to Perform 2018
Dynatrace: Accelerate your cloud innovation Welcome to Perform 2018
 
Dynatrace: Going beyond APM and soaring to the future
Dynatrace: Going beyond APM and soaring to the futureDynatrace: Going beyond APM and soaring to the future
Dynatrace: Going beyond APM and soaring to the future
 
Dynatrace: Davis - Hololens - AI update - Cloud announcements - Self driving IT
Dynatrace: Davis - Hololens - AI update - Cloud announcements - Self driving ITDynatrace: Davis - Hololens - AI update - Cloud announcements - Self driving IT
Dynatrace: Davis - Hololens - AI update - Cloud announcements - Self driving IT
 
Altimeter Group: The new face of change
Altimeter Group: The new face of changeAltimeter Group: The new face of change
Altimeter Group: The new face of change
 
Alastair Humphreys: Life stories and inspiration from Alastair Humphreys
Alastair Humphreys: Life stories and inspiration from Alastair HumphreysAlastair Humphreys: Life stories and inspiration from Alastair Humphreys
Alastair Humphreys: Life stories and inspiration from Alastair Humphreys
 
AWS: Serverless Architecture - Beyond functions and into the future
AWS: Serverless Architecture - Beyond functions and into the future AWS: Serverless Architecture - Beyond functions and into the future
AWS: Serverless Architecture - Beyond functions and into the future
 
Zurich: Monitoring a sales force-based insurance application using dynatrace ...
Zurich: Monitoring a sales force-based insurance application using dynatrace ...Zurich: Monitoring a sales force-based insurance application using dynatrace ...
Zurich: Monitoring a sales force-based insurance application using dynatrace ...
 
Sentry: Baselining, cloud-scale monitoring and auto-remediation with app mon ...
Sentry: Baselining, cloud-scale monitoring and auto-remediation with app mon ...Sentry: Baselining, cloud-scale monitoring and auto-remediation with app mon ...
Sentry: Baselining, cloud-scale monitoring and auto-remediation with app mon ...
 
SEI: Faster innovation and better performance for the innovative sei wealth p...
SEI: Faster innovation and better performance for the innovative sei wealth p...SEI: Faster innovation and better performance for the innovative sei wealth p...
SEI: Faster innovation and better performance for the innovative sei wealth p...
 
SAP: How SAP fully automates the provisioning and operations of its dynatrace...
SAP: How SAP fully automates the provisioning and operations of its dynatrace...SAP: How SAP fully automates the provisioning and operations of its dynatrace...
SAP: How SAP fully automates the provisioning and operations of its dynatrace...
 
REI: Evolving performance engineering for the move to cloud, microservices, c...
REI: Evolving performance engineering for the move to cloud, microservices, c...REI: Evolving performance engineering for the move to cloud, microservices, c...
REI: Evolving performance engineering for the move to cloud, microservices, c...
 

Último

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Último (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

Feeling the love for Node.js - The performance basics you need to know now

  • 1. © 2016 Dynatrace Feelingthe love for Node.js The performancebasicsyou needto know now
  • 2. Table of contents Executive summary Feeling the love for Node.js © 2016 Dynatrace 1 Why enterprises loveNode.js 2 The Node.js buildingblocks 8 Performance and Node.js 12 Additional resources 17
  • 3. Back to Table ofContents Feeling the love for Node.js © 2016 Dynatrace 1 Executive summary Node.js is not just new technology for the start-ups anymore. Enterprises of all types are beginning to use Node.js. But why? > Functionality that is pragmatic and smart, offering basic building blocks instead of wizardry and black box functionality designed by framework developers. > Program execution that doesn’t stop and wait when performing I/O requests, which saves system resources and provides a better overall performance. > Technology that bridges existing systems and new technologies and provides an easily deployable migration layer that either proxies data to existing systems or collects and reformats it for different uses. While Node.js has a lot of benefits, including a flat learning curve, the machinery that keeps it ticking is complex. You must understand it to avoid performance pitfalls. In this eBook, we will discuss the basic building blocks of Node.js and how memory works for Node, including garbage collection. We will also give you some tips on how to hunt down memory leaks, CPU issues, and other problems to improve performance.
  • 4. © 2016 Dynatrace Chapter1 Why enterprisesloveNode.js
  • 5. Back to Table ofContents Google searches and jobs Feeling the love for Node.js © 2016 Dynatrace 3 Seasoned developers know that every few months there is a new game-changing technology that passes into oblivion. This is not the case with Node.js. Google Trends shows search traffic by keyword over time, and is a great way to identify the relevance of a given topic, especially when correlated with other terms. When you compare search traffic on Node.js to Ruby on Rails, you can clearly see that Node.js gained momentum after its introduction in 2009 and now has beaten its competitor. Another indicator of relevance is Indeed Job Trends. If you compare job growth to other related technologies, you see Node.js again comes out ahead. Alert readers may argue that the charts looked the same for technologies like Ruby on Rails some years back. So how’s Node.js different? Big established companies with years of legacy software arenow shifting to Node.js.
  • 6. Back to Table ofContents Every new kid on the technology block gains momentum in the beginning, especially because startups tend to use the freshest technologies. But big established companies with years of legacy software are now shifting to Node.js – Walmart, eBay, PayPal, Microsoft, The New York Times, Dow Jones, etc. The list goes on. It’s uncommon for enterprises to adopt a technology like this so early in its hype cycle. We need to peek into howNode.js works to understand the reasons. What the big brands say “Node’s evented I/O model freed us from worrying about locking and concurrency issues that are common with multithreaded async I/O.” -Subbu Allarmarju, Principal Member, Technical Staff at ebay “On the server side, our entire mobile software stack is completely built in Node. One reason was scale. The second is Node showed us huge performance gains.” -Kiran Prasad, Mobile Development Lead at LinkedIn “Node.js powers our web applications andhas allowed our teams to move much faster in bringing their designs to life.” -Jeff Harrell, Director of Engineering at PayPal Feeling the love for Node.js © 2016 Dynatrace 4
  • 7. Back to Table ofContents For so many years, the trend has been toward framework and wizardry. Just enter some commands in the shell you get a full-fledged ORM layer out of your database scheme. Apparently, it seemed like a good idea to abstract as much logic as possible away from the developer and offer some easy-to-use interface for functionality that framework developers think is useful. You know those “build your own blog in five minutes” examples. Everything looks easy and great until you try to implement real requirements for real clients. It’s tempting to take the easy road and rely on generators and out-of-the-box features, but this never works out. The time you save will be spent trying to figure out why the ORM layer logic hidden deep inside the framework doesn’t let you do a select on a date range. Instead of building from your own code, you end up spending your time reading through documents, Googling, and posting on StackOverflow just to understand code written by someone else. Black magic wizadry Feeling the love for Node.js © 2016 Dynatrace 5
  • 8. Back to Table ofContents Node.js is a framework based on JavaScript that uses Google’s V8 engine. It adds functionality in a very pragmatic and smart way by offering only the basic building blocks, like file system access, protocol support, and cryptology along with some basic utility functions. Also of note, JavaScript supports event based programming — just look atthe OnClick() in browser environments — and has functions as first class members. This makes it a perfect fit for event-callback constructs that are a cornerstone of asynchronous programming. In short, this means that program execution doesn’t stop and wait when performing I/O requests, which saves system resources and provides better performance. Back to craftsmanship "Reading Node.js docs feels like Zen: reduced,focused, and concise. It feels like getting back to the essence of programming again. Nobells, no whistles.” – Daniel Khan, Technology Strategist,Dynatrace Feeling the love for Node.js © 2016 Dynatrace 6 Enterprise grade LTSis another reason to love Node.js Anew Long Term Support model was introduced in the Fall,2015. Long-term support (LTS) releases will now be actively developed for 18 months and maintained for another 12 months. So a LTS release may effectively stay in production for 30 (!) months, while still receiving bug and security fixes. For even more enterprise features and support, you can look up N|Solid.
  • 9. Back to Table ofContents During the last few years,the requirements for network- connected software systems changed dramatically. > Responsive, dynamic sites replaced static or semi-static websites for desktop computers. > Sites started to load additional content via Ajax/XHR or even rely on push technologies like WebSockets. > Streaming services began to rise in popularity. > Data of all kinds now needs to be delivered to an ever-growing number of users, with different devices in different formats. These changing and growing requirements can either be fulfilled by adding new hardware and extending existing software or by adding a new layer that uses existing infrastructure more efficiently and supports the new technologies. That's where Node.js shines — with modern, web-connected applications that need to gather data from different sources, consolidate it, and push it to many clients in real-time. It is theperfect bridging technology for existing systems because it provides an easily deployable migration layer that either proxies data to existing systems or collects and reformats data for different uses. The Node.js bridge MySQ L M ORACL E M Feeling the love for Node.js © 2016 Dynatrace 7
  • 11. Back to Table ofContents It can be a daunting task to implement a full- fledged web server when all you have is the basic HTTP commands. But not relying on complexframeworks does not mean that you have to build everything from scratch. Modules are an important building block for Node.js and expose functionality by the global data structure, module.exports. Modules are included and assigned to a variable with require(). The exported functionality is only accessible through this variable, which means that every module creates a namespace. The great thing about Node.js is that the Npm — the Node Package Manager, a collection of modules, currently holds more than 140,000 (!) packages for various purposes, and most of themare maintained on GitHub. Many of them adhere to the “Do one thing and do it well” philosophy known from UNIX. The result is a pool of small bits of functionality that can be mixed and composed as needed. There are also a few larger packages that provide a set of functionality, with express being the most popular — it provides http, routing, and template rendering functions that most web projectsneed. If you ever had to migrate a complex legacy php application to a new server, you know that this can getextremely unpleasant due to the globally installed extensions and libraries required. Thisis not the case with Node.js. In Node.js, all dependencies are registered in package.js and installed into the projects directory structure. Spinning up a new instance running an application only takes minutes with Node.js because there are no dependencies to the environment (except the node binary) and no need for a specific server environment. This makes Node.js the platform of choice for projects following the Immutable Infrastructure principle introduced by Chad Fowler in 2013. Modules, packages, and immutable infrastructure Gettingstarted On Linux use your package manager to install the latest nodejs package. For all other operating systems, download the binaries from the Node.jswebsite. Feeling the love for Node.js © 2016 Dynatrace 9 Then run Node.js applications by typing node <yourapplication.js>. Here’s a basic “Hello world” example. Run it and open http://localhost:4242 in your browser to see if everything isworking.
  • 12. Back to Table ofContents Memory in Node.js means Google V8 While Node.js has a rather flat learning curve, the machinery that keeps it ticking is quite complex. You must understand it to avoid performance pitfalls. Unlike platforms like PHP,Node.js applications are long- running processes. While this has a lot of positive implications such as allowing database connections to be set uponce and then reused for all requests, this may also cause problems. Node.js is a C++program controlled via V8 JavaScript. Google V8 is a JavaScript engine initially created for Google Chrome, but it can also be used as a standalone. This makes it the perfect fit for Node.js. V8 compiles JavaScript down to native code and executes it, and manages memory allocation. Arunning program is always represented through some space allocated in memory, the Resident Set. V8 uses a scheme similar to the Java Virtual Machine and divides the memory into segments. > Code: the actual code beingexecuted. > Stack: contains all value types (primitives like integer or Boolean) with pointers referencing objects on the heap and pointers defining the control flow of the program. > Heap: a memory segment dedicated to storing reference types likeobjects, strings, and closures. Within Node.js, current memory usage can easily be queried by calling process. memoryUsage().This function will returnan object containing: Resident Set Size, Total Sizeof theHeap, Heap Used. Youcan use this function to record the memory usage over time in a heap graph. The heap graph is highly volatile, but always stays within certain boundaries to keep the median consumption constant. The mechanism that allocates and frees heap memory is called garbage collection. Feeling the love for Node.js © 2016 Dynatrace 10
  • 13. Back to Table ofContents Understanding garbage collection Every program that consumes memory requires a mechanism for reserving and freeing space. If a program allocates memory that is never freed, the heap will constantly grow, creating a memory leak, until the usable memory is exhausted causingthe program tocrash. Because Node.js JavaScriptis compiled to native code by V8, the resulting native data structures don’t have much to do with their original representation and are solely managed by V8. This means that we cannot actively allocate or de-allocate memory in JavaScript. V8 uses garbage collection to address thisproblem. The theory behind garbage collection is simple: if a memory segment is not referenced from anywhere, wecan assume that it is notused and therefore, it can be freed. However,retrieving and maintaining this information is complex because there may be chained references and indirections that form a complex graph structure. Garbage collection is a costly process because it interrupts the execution of an application and impacts its performance. Toremedy this situation, V8 uses two types of garbagecollection: > Scavenge — fast, but incomplete > Mark-Sweep — relatively slow, but frees all non-referenced memory Revisiting the data collected from process.memoryUsage() and the chart on the previous page, you canidentify the different garbage collection types: the saw-tooth pattern is createdby Scavenge runs and the downward jumps indicate Mark-Sweep operations. By using the native module, node-gc- profiler, you can gather even more information about garbage collection runs. The module subscribes to garbage collection events fired by V8, and exposes them to JavaScript. The object returned indicates the type of garbage collection and the duration. Feeling the love for Node.js © 2016 Dynatrace 11
  • 15. Back to Table ofContents Feeling the love for Node.js © 2016 Dynatrace 13 Hunting downmemory leaks So if garbage collection cleans up the memory, why do you have to care at all?In fact, it is still possible —and easy —for memory leaks to suddenly appear in your logs. Garbage collection tries its best to free memory, but on the chart (right), we see that consumption after a garbage collection run is constantly climbing, a clear indication of aleak. Some causes of leaks are obvious — if you store data in process-global variables, like the IPof every visiting user in an array. Others are subtler like the famous Walmart memory leak that was caused by a tiny missing statement within Node.js core code, and which took weeks to track down. V8 provides a way to dump the current heap, and the V8-profiler exposes this functionality to JavaScript.Here is the code to do this. There are more sophisticated approaches to detect anomalies, but this is a good place to start. If there is a memory leak, you may end up with a significant number of heap dump files. So you should monitor this closely and add some alerting capabilities to that module.The same heap dump functionality is also provided within Chrome, and you can use Chrome developer tools to analyze the dump’s V8-profiler. One heap dump may not help you, however, because it won’t show youhow the heap develops over time. That’s why Chrome developer tools allow you to compare different memory profiles. By comparing two dumps, you get delta values that indicate which structures grew between two dumps.
  • 16. Back to Table ofContents The Node.js single thread and CPUissues The statement ‘Node.js runs in a single thread’ is only partly true. If you start up a simple applicationand look at the processes, you see that Node.js, in fact, spins up anumber of threads. This is because Node.js maintains a thread pool to delegate synchronous tasks to, while GoogleV8 creates its own threads for tasks like garbage collection. Node.js uses libuv, which provides the thread pool and an event loop to achieve asynchronous I/O. Reading a file is a synchronous input output task and can take its time. In synchronous programming, the thread runningreadfile() would now pause and wait until the system callreturns the contents of the file. That’s why, for client-server environments (like web applications), most platforms will create one thread per request. APHP application, within Apache using mod_php, works exactly like that. The “single-threaded” Node.js works differently. To not block the main thread, it delegates the readfile() task tolibuv. Libuv will then push the callback function to a queue and use some rules to determine how the task will be executed. In some cases, it will now use the thread pool to load off the work, but it may also create asynchronous tasks to behandled directly by theoperating system. The event loop continuously runs over the callback queue and will execute a callback, if the associated task hasbeen finished. The execution of the callback — and this is very important —will again run on the mainthread. Usually this works just fine, but there will be a problem if someone decides to perform a CPUconsuming operation like calculating some prime numbers inside the callback. This will block the main thread, prevent new requests from being processed and cause the application to slowdown. Feeling the love for Node.js © 2016 Dynatrace 14
  • 17. Back to Table ofContents Mind your environment (aka NODE_ENV) Most developers learn best by examples, which naturally tend to simplify matters and omit things that aren’tessential for understanding. This means that the “Hello World” example on Page7,when used as starting point for an application, may be not suitable forproduction scenarios. Environment variables are often used for distinguishing between production or development. Depending on those variables an application may turn debugging on or off, connect to a specific database, or listen on a specific port. In Node.js, NODE_ENV is used to set the current mode. If you use Express.js and install the template engine without setting NODE_ENV, it will default to development. It will switch the view cache on, which makes sense. You don’t want to restart your app to clear the cache every time you change some markup. This means your views are parsed and rendered for every request in development mode. The question is whether this causes a notable performance hit. It does. Setting NODE_ENV to production makes the application three times faster. NODE_ENV works like any other environment variable (e.g. Setting NODE_ENV PATH) and setting it depends on your platform. Linux and OSX: export NODE _ ENV=production Windows: SET NODE _ ENV=production On all platforms, you can explicitly set it when starting your application like this: NODE_ENV=production node myapp.js. You may also use a module like dotenv to set it from an .env file in your application directory. You should avoid setting the environment directly in your codebecause this contradicts the purposeof environment variables. Feeling the love for Node.js © 2016 Dynatrace 15
  • 18. CPU sampling and sunbursts Totrace down CPUheavy operations, you need a way to introspect on what’s happening on the CPUin a given time period. This introspection is called CPU sampling and luckily Google V8, the engine that compiles and executes JavaScriptin Node.js, provides a CPUsampling interface. That can be accessed from JavaScriptusing the module v8-profiler. This is the code you need to run the CPU profiler for five seconds every 30 seconds, and then store the sampling data under a timestamp-based filename. The file has a JSON tree structure, and there are a several ways to analyzeit. > Google Chrome ships with a set of developer tools useful for profiling and debugging JavaScript on websites. For a CPUintensive task, you can sort the call treeby heaviness — how much CPUtime it used in theperiod — and quickly identify the issue.This approach works when there is an issue with a singlefunction. > When the problem is more complicated, Flame charts provide an eye-friendly visualization that presents the whole call stack. Here’s a story by Netflix on how they used them to trace down a bug in their application. > Another option, Sunburst charts do a particular good job of visualizing CPU problems. In Sunburst charts, the blue center is the main function. Everyfunction called directly from main is placedin the adjacent row of the chart. If a function calls another function, it will be placed into an adjacent segment to the callingfunction. One circle segment spans all its children and the distance from the center is the depth of a function within the call tree. The angle measure represents the time a function and its children spent on the CPUwith 365° being 100% of the time. Toactually create one of these awesome charts, you can use D3.js, a popular and very powerful data visualization framework written in JavaScript. There are many code examples to show function name on a hover. You can see a full script here. Click here to open the chart in your browser and hover over thesegments to display the function names. Feeling the love for Node.js © 2016 Dynatrace 16 Back to Table ofContents
  • 19. Back to Table ofContents Additional resources With Node.js, you, can gather debugging performance data via JavaScript using v8-profiler, and analyze the data in visualization tools like D3.js. For small, single tier applications this can provide a minimal viable monitoring solution. Tosee the big picture for more complex applications, however, you need a complete performance monitoring solution. It should allow you to monitor thefull Node.js stack — everything from V8 memory analysis to drill-down intodatabase queries, code-level error diagnosis, user experience monitoring, outbound calls to external services and APIs,and server/infrastructure health analysis. Wehope this book has given you some insight on how enterprises are using Node.js and some tips on how to pinpoint performance problems. To the right are some additional resources on Node.js and performance monitoring in general. Yourhomework Videos > Walmart Node.js memory leak The blogroll > About: Performance > Joyent Blog on Walmart Node.js memory leak > The NewStack > The Netflix Tech Blog > #monitoringlife Recommended reading > Chetan Desai @Intuit > NodeSchool > 7 performance metrics to release better software, faster > DevOps hidden risks and how to achieve results Feeling the love for Node.js © 2016 Dynatrace 17
  • 20. Learn more atdynatrace.com Dynatrace is the innovator behind the industry’s premierDigital Performance Platform,makingreal-time information about digital performance visible and actionable for everyone across business and IT. We helpcustomers of all sizes see their applications and digital channels through the lens of their end users. More than 7,500organizations use these insights tomaster complexity, gain operational agility and grow revenue bydeliveringamazing customer experiences. 4.8.16 589_SS_Nodejs_jg