SlideShare une entreprise Scribd logo
1  sur  36
Télécharger pour lire hors ligne
A Node.JS Bag of Goodies for Analysing Web
                  Traffic

      Philip Tellis / philip@lognormal.com


                  ConFoo / 2012-03-02




        ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   1
Leave feeback on this talk at joind.in/5967

    ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   2
$ finger philip




       Philip Tellis
       philip@lognormal.com
       @bluesmoon
       geek - paranoid - speedfreak
       co-founder @ Log-Normal
       http://bluesmoon.info/




                  ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   3
Log-Normal




             We do real user web performance analysis




                ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   4
Log-Normal




   This talk covers some of the Node.JS modules we use to do this
                              analysis




                ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   5
Examples for this talk




         http://bluesmoon.github.com/talks/node-modules/




                ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   6
–
    Node.JS & npm



ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   7
0.1 The 2 minute Node.JS Tutorial


     node
     > m = require(’module’)
     > console.log(m.foo)

   We’ll be using node v0.6.x




                 ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   8
0.1 The 2 minute Node.JS Tutorial



     node script.js




              ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   9
0.1 The 2 minute Node.JS Tutorial



     echo "console.log(’hello, world!’)" | node

   Notice that in JavaScript, semicolons are optional




                 ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   10
0.2 Installing modules



     npm install module

   Installs into a local node_modules directory




                 ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   11
0.2 Installing modules globally



     sudo npm install -g module

   Installs into the /usr/lib/node_modules directory




                ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   12
0.2 npm help



    npm help npm




               ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   13
0.3 npmjs.org



                   search.npmjs.org




            ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   14
What’s the time?




                                     13:37?




               ConFoo / 2012-03-02    A Node.JS Bag of Goodies for Analysing Web Traffic   15
1
          HTTP Logs



ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   16
1.1 UserAgent Parsing


    npm install ua-parser

    var parser=require(’ua-parser’);
    var ua = parser.parse(ua_string);

    // family, major, minor, patch, os

  Extracted from Google’s BrowserScope Project




               ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   17
1.2 IP Addresses


    var net = require(’net’);

    net.isIP(ip);           // returns 0, 4 or 6

  The net module is part of node




               ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   18
1.3 GeoLocation


    npm install geoip-lite

    var geo = require(’geip-lite’);
    var loc = geo.lookup(ip);

    // country, region, city, ll

  Uses MaxMind’s GeoIP database. Very fast lookups, IPv4 & v6




               ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   19
1.3 geoip-lite’s hidden function


     var geo = require(’geip-lite’);
     geo.cmp(ip1, ip2);

     // -1, 0 or 1

   Used internally to do a binary search on the IP database




                 ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   20
1.4 Date formatting


     npm install prettydate

     var strftime = require(’prettydate’).strftime;

     var dstr = strftime(new Date, "%c");

   Also accepts a locale as a third parameter.




                 ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   21
1.5 Querystring Parsing


     var qs = require(’querystring’);

     qs.parse(’name=Larry&name=Moe&name=Curly’);
     // { name: [ ’Larry’, ’Moe’, ’Curly’ ] }




             ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   22
1.6 Creating Hashes


    var crypto = require(’crypto’);

    var hash = crypto.createHash(’sha1’);
    hash.update(data);

    var digest = hash.digest(’hex’);




             ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   23
1.6 Creating HMACs


    var crypto = require(’crypto’);

    var hmac = crypto.createHmac(’sha1’, key);
    hmac.update(data);

    var digest = hmac.digest(’base64’);




            ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   24
What’s the time?




                             It should be
                                 14:05
                                     I hope ;)




               ConFoo / 2012-03-02     A Node.JS Bag of Goodies for Analysing Web Traffic   25
2
Statistical Analysis



ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   26
2.1 faststats


     npm install fast-stats

     var Stats = require(’fast-stats’).Stats;
     var s = new Stats().push(1, 2, 3, 10, 8, 4, 3);
     console.log(s.amean().toFixed(2));

   Caveat: I haven’t pushed out a new version in a while




                 ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   27
2.2 gauss


    npm install gauss

    var gauss = require(’gauss’);
    var set = new gauss.Vector(5, 1, 3, 2, 21);
    console.log(set.mean());




            ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   28
2.3 statsd


    npm install statsd node-statsd

      github.com/etsy/statsd
      Easy to set up
      Requires graphite to plot charts
      Brought to you by Etsy




                ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   29
2.3 statsd



  var StatsD = require(’node-statsd’).StatsD
  c = new StatsD(’example.org’,8125)
  c.timing(’node_test.some_service.task.time’, 500)




             ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   30
2.4 cube


  Disclaimer: I’ve never used this one before

    npm install cube

      square.github.com/cube/
      github.com/square/cube/wiki




                ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   31
What’s the time?




                                     14:20?




               ConFoo / 2012-03-02    A Node.JS Bag of Goodies for Analysing Web Traffic   32
Help me out




   Still trying to figure out the best way to debug Node.JS memory
                      usage. Ideas? Let me know.




                ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   33
Questions?




ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   34
Leave feeback on this talk at joind.in/5967

    ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   35
Contact me



      Philip Tellis
      philip@lognormal.com
      @bluesmoon
      geek - paranoid - speedfreak
      co-founder @ Log-Normal
      http://bluesmoon.info/
      slideshare.net/bluesmoon
      joind.in/5967




                 ConFoo / 2012-03-02   A Node.JS Bag of Goodies for Analysing Web Traffic   36

Contenu connexe

Tendances

ApacheCon 2014 - What's New in Apache httpd 2.4
ApacheCon 2014 - What's New in Apache httpd 2.4ApacheCon 2014 - What's New in Apache httpd 2.4
ApacheCon 2014 - What's New in Apache httpd 2.4Jim Jagielski
 
Websocket protocol overview
Websocket protocol overviewWebsocket protocol overview
Websocket protocol overviewallenmeng
 
PageSpeed and SPDY
PageSpeed and SPDYPageSpeed and SPDY
PageSpeed and SPDYBlake Crosby
 
Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...
Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...
Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...Puppet
 
Mobile web performance - MoDev East
Mobile web performance - MoDev EastMobile web performance - MoDev East
Mobile web performance - MoDev EastPatrick Meenan
 
How%20to%20install%20PHP%20on%20Linux%20_%20laffers
How%20to%20install%20PHP%20on%20Linux%20_%20laffersHow%20to%20install%20PHP%20on%20Linux%20_%20laffers
How%20to%20install%20PHP%20on%20Linux%20_%20lafferstutorialsruby
 
HTTPS + Let's Encrypt
HTTPS + Let's EncryptHTTPS + Let's Encrypt
HTTPS + Let's EncryptWalter Ebert
 
Developing cacheable PHP applications - PHPLimburgBE 2018
Developing cacheable PHP applications - PHPLimburgBE 2018Developing cacheable PHP applications - PHPLimburgBE 2018
Developing cacheable PHP applications - PHPLimburgBE 2018Thijs Feryn
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ilya Grigorik
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cacheMarc Cortinas Val
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebPeter Lubbers
 
How containers helped a SaaS startup be developed and go live
How containers helped a SaaS startup be developed and go liveHow containers helped a SaaS startup be developed and go live
How containers helped a SaaS startup be developed and go liveRamon Navarro
 
Resource registries plone conf 2014
Resource registries plone conf 2014Resource registries plone conf 2014
Resource registries plone conf 2014Ramon Navarro
 
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...Ovadiah Myrgorod
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleStein Inge Morisbak
 
Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!Derek Willian Stavis
 

Tendances (20)

BPMS1
BPMS1BPMS1
BPMS1
 
ApacheCon 2014 - What's New in Apache httpd 2.4
ApacheCon 2014 - What's New in Apache httpd 2.4ApacheCon 2014 - What's New in Apache httpd 2.4
ApacheCon 2014 - What's New in Apache httpd 2.4
 
Websocket protocol overview
Websocket protocol overviewWebsocket protocol overview
Websocket protocol overview
 
Making the web faster
Making the web fasterMaking the web faster
Making the web faster
 
PageSpeed and SPDY
PageSpeed and SPDYPageSpeed and SPDY
PageSpeed and SPDY
 
Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...
Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...
Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...
 
Npm scripts
Npm scriptsNpm scripts
Npm scripts
 
Mobile web performance - MoDev East
Mobile web performance - MoDev EastMobile web performance - MoDev East
Mobile web performance - MoDev East
 
How%20to%20install%20PHP%20on%20Linux%20_%20laffers
How%20to%20install%20PHP%20on%20Linux%20_%20laffersHow%20to%20install%20PHP%20on%20Linux%20_%20laffers
How%20to%20install%20PHP%20on%20Linux%20_%20laffers
 
HTTPS + Let's Encrypt
HTTPS + Let's EncryptHTTPS + Let's Encrypt
HTTPS + Let's Encrypt
 
Developing cacheable PHP applications - PHPLimburgBE 2018
Developing cacheable PHP applications - PHPLimburgBE 2018Developing cacheable PHP applications - PHPLimburgBE 2018
Developing cacheable PHP applications - PHPLimburgBE 2018
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the Web
 
Scalable talk notes
Scalable talk notesScalable talk notes
Scalable talk notes
 
How containers helped a SaaS startup be developed and go live
How containers helped a SaaS startup be developed and go liveHow containers helped a SaaS startup be developed and go live
How containers helped a SaaS startup be developed and go live
 
Resource registries plone conf 2014
Resource registries plone conf 2014Resource registries plone conf 2014
Resource registries plone conf 2014
 
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!
 

Similaire à A Node.JS bag of goodies for analyzing Web Traffic

Windows Azure Visual Studio "Monaco"", Because it’s mundane
Windows Azure Visual Studio "Monaco"", Because it’s mundaneWindows Azure Visual Studio "Monaco"", Because it’s mundane
Windows Azure Visual Studio "Monaco"", Because it’s mundaneMike Martin
 
把鐵路開進視窗裡
把鐵路開進視窗裡把鐵路開進視窗裡
把鐵路開進視窗裡Wei Jen Lu
 
MongoDB.local Austin 2018: MongoDB Ops Manager + Kubernetes
MongoDB.local Austin 2018: MongoDB Ops Manager + KubernetesMongoDB.local Austin 2018: MongoDB Ops Manager + Kubernetes
MongoDB.local Austin 2018: MongoDB Ops Manager + KubernetesMongoDB
 
CNCF Québec Meetup du 16 Novembre 2023
CNCF Québec Meetup du 16 Novembre 2023CNCF Québec Meetup du 16 Novembre 2023
CNCF Québec Meetup du 16 Novembre 2023Anthony Dahanne
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)Felix Geisendörfer
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformniyof97
 
1st Chinaonrails Open Course 高级战略
1st Chinaonrails Open Course 高级战略1st Chinaonrails Open Course 高级战略
1st Chinaonrails Open Course 高级战略Jesse Cai
 
Happy porting x86 application to android
Happy porting x86 application to androidHappy porting x86 application to android
Happy porting x86 application to androidOwen Hsu
 
4 Node.js Gotchas: What your ops team needs to know
4 Node.js Gotchas: What your ops team needs to know4 Node.js Gotchas: What your ops team needs to know
4 Node.js Gotchas: What your ops team needs to knowDynatrace
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialTom Croucher
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevFelix Geisendörfer
 
A Continuous Packaging Pipeline
A Continuous Packaging PipelineA Continuous Packaging Pipeline
A Continuous Packaging PipelineMaciej Pasternacki
 
Intro to Node.js
Intro to Node.jsIntro to Node.js
Intro to Node.jsJames Carr
 
No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!Anthony Dahanne
 
Digital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingDigital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingHenry Schreiner
 
maven-for-maine-jug-090226091601-phpapp02.ppt
maven-for-maine-jug-090226091601-phpapp02.pptmaven-for-maine-jug-090226091601-phpapp02.ppt
maven-for-maine-jug-090226091601-phpapp02.pptnikhilmahendranath1
 
Can we run the Whole Web on Apache Sling?
Can we run the Whole Web on Apache Sling?Can we run the Whole Web on Apache Sling?
Can we run the Whole Web on Apache Sling?Bertrand Delacretaz
 
Node js javascript no lado do servidor
Node js javascript no lado do servidorNode js javascript no lado do servidor
Node js javascript no lado do servidorMauricio Vieira
 

Similaire à A Node.JS bag of goodies for analyzing Web Traffic (20)

Windows Azure Visual Studio "Monaco"", Because it’s mundane
Windows Azure Visual Studio "Monaco"", Because it’s mundaneWindows Azure Visual Studio "Monaco"", Because it’s mundane
Windows Azure Visual Studio "Monaco"", Because it’s mundane
 
把鐵路開進視窗裡
把鐵路開進視窗裡把鐵路開進視窗裡
把鐵路開進視窗裡
 
(C)NodeJS
(C)NodeJS(C)NodeJS
(C)NodeJS
 
MongoDB.local Austin 2018: MongoDB Ops Manager + Kubernetes
MongoDB.local Austin 2018: MongoDB Ops Manager + KubernetesMongoDB.local Austin 2018: MongoDB Ops Manager + Kubernetes
MongoDB.local Austin 2018: MongoDB Ops Manager + Kubernetes
 
CNCF Québec Meetup du 16 Novembre 2023
CNCF Québec Meetup du 16 Novembre 2023CNCF Québec Meetup du 16 Novembre 2023
CNCF Québec Meetup du 16 Novembre 2023
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraform
 
1st Chinaonrails Open Course 高级战略
1st Chinaonrails Open Course 高级战略1st Chinaonrails Open Course 高级战略
1st Chinaonrails Open Course 高级战略
 
Happy porting x86 application to android
Happy porting x86 application to androidHappy porting x86 application to android
Happy porting x86 application to android
 
4 Node.js Gotchas: What your ops team needs to know
4 Node.js Gotchas: What your ops team needs to know4 Node.js Gotchas: What your ops team needs to know
4 Node.js Gotchas: What your ops team needs to know
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
 
A Continuous Packaging Pipeline
A Continuous Packaging PipelineA Continuous Packaging Pipeline
A Continuous Packaging Pipeline
 
Instalação geo ip
Instalação geo ipInstalação geo ip
Instalação geo ip
 
Intro to Node.js
Intro to Node.jsIntro to Node.js
Intro to Node.js
 
No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!
 
Digital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingDigital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meeting
 
maven-for-maine-jug-090226091601-phpapp02.ppt
maven-for-maine-jug-090226091601-phpapp02.pptmaven-for-maine-jug-090226091601-phpapp02.ppt
maven-for-maine-jug-090226091601-phpapp02.ppt
 
Can we run the Whole Web on Apache Sling?
Can we run the Whole Web on Apache Sling?Can we run the Whole Web on Apache Sling?
Can we run the Whole Web on Apache Sling?
 
Node js javascript no lado do servidor
Node js javascript no lado do servidorNode js javascript no lado do servidor
Node js javascript no lado do servidor
 

Plus de Philip Tellis

Improving D3 Performance with CANVAS and other Hacks
Improving D3 Performance with CANVAS and other HacksImproving D3 Performance with CANVAS and other Hacks
Improving D3 Performance with CANVAS and other HacksPhilip Tellis
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonPhilip Tellis
 
Frontend Performance: De débutant à Expert à Fou Furieux
Frontend Performance: De débutant à Expert à Fou FurieuxFrontend Performance: De débutant à Expert à Fou Furieux
Frontend Performance: De débutant à Expert à Fou FurieuxPhilip Tellis
 
Frontend Performance: Expert to Crazy Person
Frontend Performance: Expert to Crazy PersonFrontend Performance: Expert to Crazy Person
Frontend Performance: Expert to Crazy PersonPhilip Tellis
 
Beyond Page Level Metrics
Beyond Page Level MetricsBeyond Page Level Metrics
Beyond Page Level MetricsPhilip Tellis
 
Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...
Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...
Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...Philip Tellis
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonPhilip Tellis
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonPhilip Tellis
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonPhilip Tellis
 
RUM Distillation 101 -- Part I
RUM Distillation 101 -- Part IRUM Distillation 101 -- Part I
RUM Distillation 101 -- Part IPhilip Tellis
 
Improving 3rd Party Script Performance With IFrames
Improving 3rd Party Script Performance With IFramesImproving 3rd Party Script Performance With IFrames
Improving 3rd Party Script Performance With IFramesPhilip Tellis
 
Abusing JavaScript to measure Web Performance, or, "how does boomerang work?"
Abusing JavaScript to measure Web Performance, or, "how does boomerang work?"Abusing JavaScript to measure Web Performance, or, "how does boomerang work?"
Abusing JavaScript to measure Web Performance, or, "how does boomerang work?"Philip Tellis
 
The Statistics of Web Performance Analysis
The Statistics of Web Performance AnalysisThe Statistics of Web Performance Analysis
The Statistics of Web Performance AnalysisPhilip Tellis
 
Abusing JavaScript to Measure Web Performance
Abusing JavaScript to Measure Web PerformanceAbusing JavaScript to Measure Web Performance
Abusing JavaScript to Measure Web PerformancePhilip Tellis
 
Analysing network characteristics with JavaScript
Analysing network characteristics with JavaScriptAnalysing network characteristics with JavaScript
Analysing network characteristics with JavaScriptPhilip Tellis
 
Messing with JavaScript and the DOM to measure network characteristics
Messing with JavaScript and the DOM to measure network characteristicsMessing with JavaScript and the DOM to measure network characteristics
Messing with JavaScript and the DOM to measure network characteristicsPhilip Tellis
 

Plus de Philip Tellis (20)

Improving D3 Performance with CANVAS and other Hacks
Improving D3 Performance with CANVAS and other HacksImproving D3 Performance with CANVAS and other Hacks
Improving D3 Performance with CANVAS and other Hacks
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy Person
 
Frontend Performance: De débutant à Expert à Fou Furieux
Frontend Performance: De débutant à Expert à Fou FurieuxFrontend Performance: De débutant à Expert à Fou Furieux
Frontend Performance: De débutant à Expert à Fou Furieux
 
Frontend Performance: Expert to Crazy Person
Frontend Performance: Expert to Crazy PersonFrontend Performance: Expert to Crazy Person
Frontend Performance: Expert to Crazy Person
 
Beyond Page Level Metrics
Beyond Page Level MetricsBeyond Page Level Metrics
Beyond Page Level Metrics
 
Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...
Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...
Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy Person
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy Person
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy Person
 
mmm... beacons
mmm... beaconsmmm... beacons
mmm... beacons
 
RUM Distillation 101 -- Part I
RUM Distillation 101 -- Part IRUM Distillation 101 -- Part I
RUM Distillation 101 -- Part I
 
Improving 3rd Party Script Performance With IFrames
Improving 3rd Party Script Performance With IFramesImproving 3rd Party Script Performance With IFrames
Improving 3rd Party Script Performance With IFrames
 
Extending Boomerang
Extending BoomerangExtending Boomerang
Extending Boomerang
 
Abusing JavaScript to measure Web Performance, or, "how does boomerang work?"
Abusing JavaScript to measure Web Performance, or, "how does boomerang work?"Abusing JavaScript to measure Web Performance, or, "how does boomerang work?"
Abusing JavaScript to measure Web Performance, or, "how does boomerang work?"
 
The Statistics of Web Performance Analysis
The Statistics of Web Performance AnalysisThe Statistics of Web Performance Analysis
The Statistics of Web Performance Analysis
 
Abusing JavaScript to Measure Web Performance
Abusing JavaScript to Measure Web PerformanceAbusing JavaScript to Measure Web Performance
Abusing JavaScript to Measure Web Performance
 
Rum for Breakfast
Rum for BreakfastRum for Breakfast
Rum for Breakfast
 
Analysing network characteristics with JavaScript
Analysing network characteristics with JavaScriptAnalysing network characteristics with JavaScript
Analysing network characteristics with JavaScript
 
Input sanitization
Input sanitizationInput sanitization
Input sanitization
 
Messing with JavaScript and the DOM to measure network characteristics
Messing with JavaScript and the DOM to measure network characteristicsMessing with JavaScript and the DOM to measure network characteristics
Messing with JavaScript and the DOM to measure network characteristics
 

Dernier

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Dernier (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

A Node.JS bag of goodies for analyzing Web Traffic

  • 1. A Node.JS Bag of Goodies for Analysing Web Traffic Philip Tellis / philip@lognormal.com ConFoo / 2012-03-02 ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 1
  • 2. Leave feeback on this talk at joind.in/5967 ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 2
  • 3. $ finger philip Philip Tellis philip@lognormal.com @bluesmoon geek - paranoid - speedfreak co-founder @ Log-Normal http://bluesmoon.info/ ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 3
  • 4. Log-Normal We do real user web performance analysis ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 4
  • 5. Log-Normal This talk covers some of the Node.JS modules we use to do this analysis ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 5
  • 6. Examples for this talk http://bluesmoon.github.com/talks/node-modules/ ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 6
  • 7. Node.JS & npm ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 7
  • 8. 0.1 The 2 minute Node.JS Tutorial node > m = require(’module’) > console.log(m.foo) We’ll be using node v0.6.x ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 8
  • 9. 0.1 The 2 minute Node.JS Tutorial node script.js ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 9
  • 10. 0.1 The 2 minute Node.JS Tutorial echo "console.log(’hello, world!’)" | node Notice that in JavaScript, semicolons are optional ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 10
  • 11. 0.2 Installing modules npm install module Installs into a local node_modules directory ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 11
  • 12. 0.2 Installing modules globally sudo npm install -g module Installs into the /usr/lib/node_modules directory ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 12
  • 13. 0.2 npm help npm help npm ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 13
  • 14. 0.3 npmjs.org search.npmjs.org ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 14
  • 15. What’s the time? 13:37? ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 15
  • 16. 1 HTTP Logs ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 16
  • 17. 1.1 UserAgent Parsing npm install ua-parser var parser=require(’ua-parser’); var ua = parser.parse(ua_string); // family, major, minor, patch, os Extracted from Google’s BrowserScope Project ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 17
  • 18. 1.2 IP Addresses var net = require(’net’); net.isIP(ip); // returns 0, 4 or 6 The net module is part of node ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 18
  • 19. 1.3 GeoLocation npm install geoip-lite var geo = require(’geip-lite’); var loc = geo.lookup(ip); // country, region, city, ll Uses MaxMind’s GeoIP database. Very fast lookups, IPv4 & v6 ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 19
  • 20. 1.3 geoip-lite’s hidden function var geo = require(’geip-lite’); geo.cmp(ip1, ip2); // -1, 0 or 1 Used internally to do a binary search on the IP database ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 20
  • 21. 1.4 Date formatting npm install prettydate var strftime = require(’prettydate’).strftime; var dstr = strftime(new Date, "%c"); Also accepts a locale as a third parameter. ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 21
  • 22. 1.5 Querystring Parsing var qs = require(’querystring’); qs.parse(’name=Larry&name=Moe&name=Curly’); // { name: [ ’Larry’, ’Moe’, ’Curly’ ] } ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 22
  • 23. 1.6 Creating Hashes var crypto = require(’crypto’); var hash = crypto.createHash(’sha1’); hash.update(data); var digest = hash.digest(’hex’); ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 23
  • 24. 1.6 Creating HMACs var crypto = require(’crypto’); var hmac = crypto.createHmac(’sha1’, key); hmac.update(data); var digest = hmac.digest(’base64’); ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 24
  • 25. What’s the time? It should be 14:05 I hope ;) ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 25
  • 26. 2 Statistical Analysis ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 26
  • 27. 2.1 faststats npm install fast-stats var Stats = require(’fast-stats’).Stats; var s = new Stats().push(1, 2, 3, 10, 8, 4, 3); console.log(s.amean().toFixed(2)); Caveat: I haven’t pushed out a new version in a while ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 27
  • 28. 2.2 gauss npm install gauss var gauss = require(’gauss’); var set = new gauss.Vector(5, 1, 3, 2, 21); console.log(set.mean()); ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 28
  • 29. 2.3 statsd npm install statsd node-statsd github.com/etsy/statsd Easy to set up Requires graphite to plot charts Brought to you by Etsy ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 29
  • 30. 2.3 statsd var StatsD = require(’node-statsd’).StatsD c = new StatsD(’example.org’,8125) c.timing(’node_test.some_service.task.time’, 500) ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 30
  • 31. 2.4 cube Disclaimer: I’ve never used this one before npm install cube square.github.com/cube/ github.com/square/cube/wiki ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 31
  • 32. What’s the time? 14:20? ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 32
  • 33. Help me out Still trying to figure out the best way to debug Node.JS memory usage. Ideas? Let me know. ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 33
  • 34. Questions? ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 34
  • 35. Leave feeback on this talk at joind.in/5967 ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 35
  • 36. Contact me Philip Tellis philip@lognormal.com @bluesmoon geek - paranoid - speedfreak co-founder @ Log-Normal http://bluesmoon.info/ slideshare.net/bluesmoon joind.in/5967 ConFoo / 2012-03-02 A Node.JS Bag of Goodies for Analysing Web Traffic 36