Click here to load reader

Dont let just Node.js Take the Blame @NodeInteractive Austin

  • View
    181

  • Download
    0

Embed Size (px)

Text of Dont let just Node.js Take the Blame @NodeInteractive Austin

Dont let just Node.js take the BlameDaniel Khan, Dynatrace

2

@dkhan

We are famous for Mozart, Red Bull and Californian Governors.3

And this is how we look like on Sundays.4

When I started my career 15 years ago websites looked like this.Cats already dominated the internet.We hated JavaScript. I cant believe that now 15 years afterwards I am giving a talk about server side JavaScript in San Francisco.5

6

@dkhan

7

Node.js is what the Company Outlaws use to finally introduce change

Node.js is what the Company Hipsters threw in just to break everything

Proactive Defense

Node.js is a C++ program controlled by V8 JavaScript

But I really like this definition.

16

What V8 does: It translates JavaScript into machine code and runs it.17

And every running program is represented by

Work done on the CPUData Stoed im memory

And here we already have our two problem classes.19

Hunting Memory Problems

Lets review the memory handling of Node.jsIts very common and quite like Java.

RSS: Code and Stack where local variables are storedIt contains the heap for where objects and closures lets say long living resources like objects or closures are stored21

process.memoryUsage()

{ rss: 4935680, heapTotal: 1826816, heapUsed: 650472 }

And its actually very easy to query the memory usage of a given Node process.22

And this is what you get if you create a graph of a running Node application.As we already see the heapUsed graph looks funny.It somehow is very dynamic and seems to follow a pattern.Something seems to take care that memory is freed. And I have a real live example of how this works.23

26

The console spits this out30

How to build a Memory Leak

And now that we have found our problem we can add this. And the weekend is saved.34

theThingsomeMethod()longStrunused()originalThingClosure ContextReferenceRoot

36

37

http://bit.ly/1PvijIyvar snap = profiler.takeSnapshot();snap.serialize();v8-profiler

My script will look at the memory usage and it constantly grows it will create a snapshot.38

Delta

Hunting CPU Problems

The Node.js Event Loop!

calculateFibonacci();

43

http://bit.ly/1jQMbBRprofiler.startProfiling(id); profiler.stopProfiling(id); v8-profiler

Again v8 profiler. Again a function already there in V8.This will give you this.44

NODE_ENV=productionNODE_ENV=developmentBlog: http://bit.ly/1flz0XmNODE_ENV=developmentNODE_ENV=production

So this netflix latency problem.46

get(/routeA, function(){})get(/routeB, function(){})get(/routeC, function(){})get(/routeD, function(){})get(/routeE, function(){})get(/routeA, function(){})get(/routeX, function(){})get(/^(route|router)\/(.+), function(){})HTTP GET /routeXget(/routeA, function(){})get(/routeX, function(){})O(n)

47

Finding the route

Tools for Node.js Monitoring

50

56

19802000

1995

2005

20102015

Stakeholders

60

Backpressure

62

1000 RPSNode.js

10 RPSAncient Legacy Backend

63

We who cut mere stones must always be envisioning cathedrals.

Quarry worker's creed

Meet Application Performance Monitoring

Transactional Tracing in Node.js

Complete Transaction Coverage

Browser / Native MobileJava/.NET

PerformanceWarehousePurePathCollectorDynatraceServerDynatraceClientSessionsStoreExportedSession

OfflineSession Analysis

Web Server/ PHP/ Node.jsC++, VB, ADK

CICSMainframez/OSMQ/ESB

Database

Automatic Browser Injection for UEMEliminate guesswork across the lifecycleNo averages 100% all Transactions Low maintenancePrivate and Public cloud environments

70

Dedicated Monitoring and Debugging Tools SummaryUse Tracing Tools that follow your Transactions

@dkhanDaniel Khandaniel.khan@dynatrace.com

Speaking about Node.js lets outline what this talk is about.

When ever theres bad press about Node.js its about performance problems.Here are two examples.79

Search related