SlideShare une entreprise Scribd logo
1  sur  34
Télécharger pour lire hors ligne
DashProfiler
Lightweight Code Instrumentation




Tim.Bunce@pobox.com - July 2008
A Problem

A web application ~100K lines of code
Using many external services
If response time goes up... what’s causing it?
A Problem

A web application ~100K lines of code
Using many external services
If response time goes up... what’s causing it?

Continuous monitoring in production
Must have very low CPU and I/O cost
Minimal code changes
A Typical Approach
 package MyNetIO;



 sub send_request {
    my ($hostname, $request) = @_


     ...send to $hostname...


 }



How much time was spent sending the request?
A Typical Approach
package MyNetIO;

use Time::Hires qw(time);

sub send_request {
   my ($hostname, $request) = @_
   my $start = time();

    ...send to $hostname...

    $durations->{MyNetIO}{$hostname} = time() - $start;
}
A Typical Approach
   package MyNetIO;

   use Time::Hires qw(time);

   sub send_request {
      my ($hostname, $request) = @_
      my $start = time();

       ...send to $hostname...

       $durations->{MyNetIO}{$hostname} = time() - $start;
   }

• Doesn’t record count so can’t produce averages.
A Typical Approach
   package MyNetIO;

   use Time::Hires qw(time);

   sub send_request {
      my ($hostname, $request) = @_
      my $start = time();

       ...send to $hostname...

       $durations->{MyNetIO}{$hostname} = time() - $start;
   }

• Doesn’t record count so can’t produce averages.
• Two lines of code. Worse if multiple return statements.
A Typical Approach
   package MyNetIO;

   use Time::Hires qw(time);

   sub send_request {
      my ($hostname, $request) = @_
      my $start = time();

       ...send to $hostname...

       $durations->{MyNetIO}{$hostname} = time() - $start;
   }

• Doesn’t record count so can’t produce averages.
• Two lines of code. Worse if multiple return statements.
• Doesn’t record time if function exits via an exception.
A Solution: DashProfiler

        Simple
        Flexible
      Lightweight
DashProfiler

• Can group samples into granular time units

• Can measure exclusive time in a period

• Can flush to disk at intervals

• Just needs one line of code per sample
DashProfiler Internals

Built on DBI::Profile, part of the DBI

Aggregates measurements into a data tree

Two-level tree by default:

  $root->{ $key1 }->{ $key2 }->[ ...leaf node... ]

  $root->{ ‘MyNetIO’ }->{ $hostname }->[ ...leaf node... ]
DashProfiler Data
Each leaf node in the tree is a reference to an array:

$root->{ $key1 }->{ $key2     }   = [
    106,                      #   0: count of samples at this node
    0.0312958955764771,       #   1: total duration
    0.000490069389343262,     #   2: first duration
    0.000176072120666504,     #   3: shortest duration
    0.00140702724456787,      #   4: longest duration
    1023115819.83019,         #   5: time of first sample
    1023115819.86576,         #   6: time of last sample
  ]
DashProfiler By-Time

Optional extra time level in the data tree

  $time = int(time() / $granularity) * $granularity;

  $root->{ $time }->{ ‘MyNetIO’ }->{ $hostname }->[ ... ]


So a new sub-tree is grown each granularity seconds
DashProfiler Config
use DashProfiler;

DashProfiler->add_profile( foo => { } );

DashProfiler->add_profile( foo => {
   granularity => 10,
   flush_interval => 600,
   flush_hook => sub { ... },
   sample_class => ‘DashProfiler::Sample’,
   dbi_profile_class => ‘DBI::Profile’,
   period_exclusive => ...,
   period_summary => ...,
   ...
   });
Without DashProfiler

package MyNetIO;

use Time::Hires qw(time);

sub send_request {
   my ($hostname, $request) = @_
   my $start = time();

    ...send to $hostname...

    $durations->{MyNetIO}{$hostname} = time() - $start;
}
Without DashProfiler

package MyNetIO;

use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ];

sub send_request {
   my ($hostname, $request) = @_
   my $sample = foo_profiler( $hostname );

    ...send to $hostname...


}
With DashProfiler

package MyNetIO;

use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ];

sub send_request {
   my ($hostname, $request) = @_
   my $sample = foo_profiler( $hostname );

    ...send to $hostname...


}
       Duration is measured when
       $sample goes out of scope
With DashProfiler
                   Name of profile created with add_profile()


package MyNetIO;

use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ];

sub send_request {
   my ($hostname, $request) = @_
   my $sample = foo_profiler( $hostname );

    ...send to $hostname...


}
       Duration is measured when
       $sample goes out of scope
With DashProfiler
                   Name of profile created with add_profile()

                                      Value to use for ‘key1’
package MyNetIO;

use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ];

sub send_request {
   my ($hostname, $request) = @_
   my $sample = foo_profiler( $hostname );

    ...send to $hostname...


}
       Duration is measured when
       $sample goes out of scope
With DashProfiler
                   Name of profile created with add_profile()

                                      Value to use for ‘key1’
package MyNetIO;

use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ];

sub send_request {
                                      Value to use for ‘key2’
   my ($hostname, $request) = @_
   my $sample = foo_profiler( $hostname );

    ...send to $hostname...


}
       Duration is measured when
       $sample goes out of scope
With DashProfiler

package MyNetIO;

use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ];

sub send_request {
   my ($hostname, $request) = @_
   my $sample = foo_profiler( $hostname )
       if foo_profiler_enabled();

    ...send to $hostname...

}
With DashProfiler

package MyNetIO;

use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ];

sub send_request {
   my ($hostname, $request) = @_
   my $sample = foo_profiler( $hostname )
       if foo_profiler_enabled();

    ...send to $hostname...
                                   Automatically imported
                                   compile-time constant
}                                    reduces cost to zero
                                    if profile is disabled
DashProfiler Flush
Data is written to STDERR on exit, by default
Regular flushing is enabled by specifying a flush_interval
The dbi_profile_class handles the flush. Choices include:
  DBI::Profile
  DBI::ProfileData
  DBI::ProfileData::Apache

DashProfiler->add_profile( foo => {
   ...,
   flush_interval => 600,
   dbi_profile_class => ‘DBI::ProfileData’,
   flush_hook => sub { ... },
   ...
});
DashProfiler Periods
• Group samples into periods
  - e.g. http request to response
  -   start_sample_period() and end_sample_period()
  - counted, to enable averages and totals per period
  - can output period counts instead of sample counts


• Measure ‘exclusive’ time
  - time from period start to end that’s not been
    accounted for by other samples
  - enabled via period_exclusive option
Example Data
Average response times over 24 hours




           DashProfiler doesn’t generate graphs itself, but the
                 data can be used to create graphs like these
Example Data
Worst case response times over 24 hours
DashProfiler Perspectives
• Each DashProfiler can have multiple DBI
    Profile objects attached
•   Samples accumulate in all attached profiles
•   Each profile can have a different Path
•   giving different ‘perspectives’ or level of detail
    -   key1 + key2
    -   key1 + country + browser type
    -   key2 + browser type
    -   ... etc.
DashProfiler Per-Period
• Optional extra ‘per-period’ DBI profile
• Enabled via period_summary option
• Automatically attached and reset by
  start_sample_period()

• Gives current totals for this period
• Great for ‘debug footers’ on web page showing
  how much time was spent generating this page
DashProfiler Cost
DashProfiler Cost

Time cost of taking a sample:

     0.000022s
Questions?

Contenu connexe

Tendances

PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language TriviaNikita Popov
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)Night Sailer
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Masahiro Nagano
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica SetsMongoDB
 
Cs757 ns2-tutorial-exercise
Cs757 ns2-tutorial-exerciseCs757 ns2-tutorial-exercise
Cs757 ns2-tutorial-exercisePratik Joshi
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RIThe Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RIEleanor McHugh
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with PuppetWalter Heck
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with PuppetOlinData
 
(Greach 2015) Dsl'ing your Groovy
(Greach 2015) Dsl'ing your Groovy(Greach 2015) Dsl'ing your Groovy
(Greach 2015) Dsl'ing your GroovyAlonso Torres
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Remy Sharp
 
Groovy Fly Through
Groovy Fly ThroughGroovy Fly Through
Groovy Fly Throughniklal
 
Abusing text/template for data transformation
Abusing text/template for data transformationAbusing text/template for data transformation
Abusing text/template for data transformationArnaud Porterie
 
Generated Power: PHP 5.5 Generators
Generated Power: PHP 5.5 GeneratorsGenerated Power: PHP 5.5 Generators
Generated Power: PHP 5.5 GeneratorsMark Baker
 
Perl: Hate it for the Right Reasons
Perl: Hate it for the Right ReasonsPerl: Hate it for the Right Reasons
Perl: Hate it for the Right ReasonsMatt Follett
 

Tendances (20)

PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language Trivia
 
Perl object ?
Perl object ?Perl object ?
Perl object ?
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
 
Perl Web Client
Perl Web ClientPerl Web Client
Perl Web Client
 
Nubilus Perl
Nubilus PerlNubilus Perl
Nubilus Perl
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica Sets
 
Follow the White Rabbit - Message Queues with PHP
Follow the White Rabbit - Message Queues with PHPFollow the White Rabbit - Message Queues with PHP
Follow the White Rabbit - Message Queues with PHP
 
Cs757 ns2-tutorial-exercise
Cs757 ns2-tutorial-exerciseCs757 ns2-tutorial-exercise
Cs757 ns2-tutorial-exercise
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RIThe Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
 
(Greach 2015) Dsl'ing your Groovy
(Greach 2015) Dsl'ing your Groovy(Greach 2015) Dsl'ing your Groovy
(Greach 2015) Dsl'ing your Groovy
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)
 
Groovy Fly Through
Groovy Fly ThroughGroovy Fly Through
Groovy Fly Through
 
Abusing text/template for data transformation
Abusing text/template for data transformationAbusing text/template for data transformation
Abusing text/template for data transformation
 
Generated Power: PHP 5.5 Generators
Generated Power: PHP 5.5 GeneratorsGenerated Power: PHP 5.5 Generators
Generated Power: PHP 5.5 Generators
 
Format String Exploitation
Format String ExploitationFormat String Exploitation
Format String Exploitation
 
Perl: Hate it for the Right Reasons
Perl: Hate it for the Right ReasonsPerl: Hate it for the Right Reasons
Perl: Hate it for the Right Reasons
 

En vedette

Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12Tim Bunce
 
Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )Tim Bunce
 
Perl Memory Use 201209
Perl Memory Use 201209Perl Memory Use 201209
Perl Memory Use 201209Tim Bunce
 
PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012Tim Bunce
 
Perl Dist::Surveyor 2011
Perl Dist::Surveyor 2011Perl Dist::Surveyor 2011
Perl Dist::Surveyor 2011Tim Bunce
 
Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406Tim Bunce
 
Perl Memory Use - LPW2013
Perl Memory Use - LPW2013Perl Memory Use - LPW2013
Perl Memory Use - LPW2013Tim Bunce
 
Perl6 DBDI YAPC::EU 201008
Perl6 DBDI YAPC::EU 201008Perl6 DBDI YAPC::EU 201008
Perl6 DBDI YAPC::EU 201008Tim Bunce
 

En vedette (8)

Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12
 
Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )
 
Perl Memory Use 201209
Perl Memory Use 201209Perl Memory Use 201209
Perl Memory Use 201209
 
PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012
 
Perl Dist::Surveyor 2011
Perl Dist::Surveyor 2011Perl Dist::Surveyor 2011
Perl Dist::Surveyor 2011
 
Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406
 
Perl Memory Use - LPW2013
Perl Memory Use - LPW2013Perl Memory Use - LPW2013
Perl Memory Use - LPW2013
 
Perl6 DBDI YAPC::EU 201008
Perl6 DBDI YAPC::EU 201008Perl6 DBDI YAPC::EU 201008
Perl6 DBDI YAPC::EU 201008
 

Similaire à DashProfiler 200807

Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony TechniquesKris Wallsmith
 
Filesystem abstractions and msg queue sergeev - symfony camp 2018
Filesystem abstractions and msg queue   sergeev - symfony camp 2018Filesystem abstractions and msg queue   sergeev - symfony camp 2018
Filesystem abstractions and msg queue sergeev - symfony camp 2018Юлия Коваленко
 
Facebook的缓存系统
Facebook的缓存系统Facebook的缓存系统
Facebook的缓存系统yiditushe
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2Elizabeth Smith
 
4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebookguoqing75
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuningAOE
 
Pim Elshoff "Technically DDD"
Pim Elshoff "Technically DDD"Pim Elshoff "Technically DDD"
Pim Elshoff "Technically DDD"Fwdays
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the CloudWesley Beary
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)Wesley Beary
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot CampTroy Miles
 
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Jeff Carouth
 
Stack kicker devopsdays-london-2013
Stack kicker devopsdays-london-2013Stack kicker devopsdays-london-2013
Stack kicker devopsdays-london-2013Simon McCartney
 
Operation Oriented Web Applications / Yokohama pm7
Operation Oriented Web Applications / Yokohama pm7Operation Oriented Web Applications / Yokohama pm7
Operation Oriented Web Applications / Yokohama pm7Masahiro Nagano
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScriptQiangning Hong
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony AppsKris Wallsmith
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On RailsJohn Wilker
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 WorldFabien Potencier
 

Similaire à DashProfiler 200807 (20)

Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
Filesystem abstractions and msg queue sergeev - symfony camp 2018
Filesystem abstractions and msg queue   sergeev - symfony camp 2018Filesystem abstractions and msg queue   sergeev - symfony camp 2018
Filesystem abstractions and msg queue sergeev - symfony camp 2018
 
Facebook的缓存系统
Facebook的缓存系统Facebook的缓存系统
Facebook的缓存系统
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2
 
4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook
 
PHP code examples
PHP code examplesPHP code examples
PHP code examples
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
 
Couchdb
CouchdbCouchdb
Couchdb
 
Pim Elshoff "Technically DDD"
Pim Elshoff "Technically DDD"Pim Elshoff "Technically DDD"
Pim Elshoff "Technically DDD"
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4
 
Stack kicker devopsdays-london-2013
Stack kicker devopsdays-london-2013Stack kicker devopsdays-london-2013
Stack kicker devopsdays-london-2013
 
Operation Oriented Web Applications / Yokohama pm7
Operation Oriented Web Applications / Yokohama pm7Operation Oriented Web Applications / Yokohama pm7
Operation Oriented Web Applications / Yokohama pm7
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript
 
Tt subtemplates-caching
Tt subtemplates-cachingTt subtemplates-caching
Tt subtemplates-caching
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On Rails
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
 

Plus de Tim Bunce

Application Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyApplication Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyTim Bunce
 
Perl 6 DBDI 201007 (OUTDATED, see 201008)
Perl 6 DBDI 201007 (OUTDATED, see 201008)Perl 6 DBDI 201007 (OUTDATED, see 201008)
Perl 6 DBDI 201007 (OUTDATED, see 201008)Tim Bunce
 
PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0Tim Bunce
 
DBI Advanced Tutorial 2007
DBI Advanced Tutorial 2007DBI Advanced Tutorial 2007
DBI Advanced Tutorial 2007Tim Bunce
 
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)Tim Bunce
 
Perl Myths 200909
Perl Myths 200909Perl Myths 200909
Perl Myths 200909Tim Bunce
 
DBI for Parrot and Perl 6 Lightning Talk 2007
DBI for Parrot and Perl 6 Lightning Talk 2007DBI for Parrot and Perl 6 Lightning Talk 2007
DBI for Parrot and Perl 6 Lightning Talk 2007Tim Bunce
 
DBD::Gofer 200809
DBD::Gofer 200809DBD::Gofer 200809
DBD::Gofer 200809Tim Bunce
 
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Devel::NYTProf 2009-07 (OUTDATED, see 201008)Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Devel::NYTProf 2009-07 (OUTDATED, see 201008)Tim Bunce
 
Perl Myths 200802 with notes (OUTDATED, see 200909)
Perl Myths 200802 with notes (OUTDATED, see 200909)Perl Myths 200802 with notes (OUTDATED, see 200909)
Perl Myths 200802 with notes (OUTDATED, see 200909)Tim Bunce
 

Plus de Tim Bunce (10)

Application Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyApplication Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.key
 
Perl 6 DBDI 201007 (OUTDATED, see 201008)
Perl 6 DBDI 201007 (OUTDATED, see 201008)Perl 6 DBDI 201007 (OUTDATED, see 201008)
Perl 6 DBDI 201007 (OUTDATED, see 201008)
 
PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0
 
DBI Advanced Tutorial 2007
DBI Advanced Tutorial 2007DBI Advanced Tutorial 2007
DBI Advanced Tutorial 2007
 
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
 
Perl Myths 200909
Perl Myths 200909Perl Myths 200909
Perl Myths 200909
 
DBI for Parrot and Perl 6 Lightning Talk 2007
DBI for Parrot and Perl 6 Lightning Talk 2007DBI for Parrot and Perl 6 Lightning Talk 2007
DBI for Parrot and Perl 6 Lightning Talk 2007
 
DBD::Gofer 200809
DBD::Gofer 200809DBD::Gofer 200809
DBD::Gofer 200809
 
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Devel::NYTProf 2009-07 (OUTDATED, see 201008)Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
 
Perl Myths 200802 with notes (OUTDATED, see 200909)
Perl Myths 200802 with notes (OUTDATED, see 200909)Perl Myths 200802 with notes (OUTDATED, see 200909)
Perl Myths 200802 with notes (OUTDATED, see 200909)
 

Dernier

Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 

Dernier (20)

Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 

DashProfiler 200807

  • 2. A Problem A web application ~100K lines of code Using many external services If response time goes up... what’s causing it?
  • 3. A Problem A web application ~100K lines of code Using many external services If response time goes up... what’s causing it? Continuous monitoring in production Must have very low CPU and I/O cost Minimal code changes
  • 4. A Typical Approach package MyNetIO; sub send_request { my ($hostname, $request) = @_ ...send to $hostname... } How much time was spent sending the request?
  • 5. A Typical Approach package MyNetIO; use Time::Hires qw(time); sub send_request { my ($hostname, $request) = @_ my $start = time(); ...send to $hostname... $durations->{MyNetIO}{$hostname} = time() - $start; }
  • 6. A Typical Approach package MyNetIO; use Time::Hires qw(time); sub send_request { my ($hostname, $request) = @_ my $start = time(); ...send to $hostname... $durations->{MyNetIO}{$hostname} = time() - $start; } • Doesn’t record count so can’t produce averages.
  • 7. A Typical Approach package MyNetIO; use Time::Hires qw(time); sub send_request { my ($hostname, $request) = @_ my $start = time(); ...send to $hostname... $durations->{MyNetIO}{$hostname} = time() - $start; } • Doesn’t record count so can’t produce averages. • Two lines of code. Worse if multiple return statements.
  • 8. A Typical Approach package MyNetIO; use Time::Hires qw(time); sub send_request { my ($hostname, $request) = @_ my $start = time(); ...send to $hostname... $durations->{MyNetIO}{$hostname} = time() - $start; } • Doesn’t record count so can’t produce averages. • Two lines of code. Worse if multiple return statements. • Doesn’t record time if function exits via an exception.
  • 9. A Solution: DashProfiler Simple Flexible Lightweight
  • 10. DashProfiler • Can group samples into granular time units • Can measure exclusive time in a period • Can flush to disk at intervals • Just needs one line of code per sample
  • 11. DashProfiler Internals Built on DBI::Profile, part of the DBI Aggregates measurements into a data tree Two-level tree by default: $root->{ $key1 }->{ $key2 }->[ ...leaf node... ] $root->{ ‘MyNetIO’ }->{ $hostname }->[ ...leaf node... ]
  • 12. DashProfiler Data Each leaf node in the tree is a reference to an array: $root->{ $key1 }->{ $key2 } = [ 106, # 0: count of samples at this node 0.0312958955764771, # 1: total duration 0.000490069389343262, # 2: first duration 0.000176072120666504, # 3: shortest duration 0.00140702724456787, # 4: longest duration 1023115819.83019, # 5: time of first sample 1023115819.86576, # 6: time of last sample ]
  • 13. DashProfiler By-Time Optional extra time level in the data tree $time = int(time() / $granularity) * $granularity; $root->{ $time }->{ ‘MyNetIO’ }->{ $hostname }->[ ... ] So a new sub-tree is grown each granularity seconds
  • 14. DashProfiler Config use DashProfiler; DashProfiler->add_profile( foo => { } ); DashProfiler->add_profile( foo => { granularity => 10, flush_interval => 600, flush_hook => sub { ... }, sample_class => ‘DashProfiler::Sample’, dbi_profile_class => ‘DBI::Profile’, period_exclusive => ..., period_summary => ..., ... });
  • 15. Without DashProfiler package MyNetIO; use Time::Hires qw(time); sub send_request { my ($hostname, $request) = @_ my $start = time(); ...send to $hostname... $durations->{MyNetIO}{$hostname} = time() - $start; }
  • 16. Without DashProfiler package MyNetIO; use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ]; sub send_request { my ($hostname, $request) = @_ my $sample = foo_profiler( $hostname ); ...send to $hostname... }
  • 17. With DashProfiler package MyNetIO; use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ]; sub send_request { my ($hostname, $request) = @_ my $sample = foo_profiler( $hostname ); ...send to $hostname... } Duration is measured when $sample goes out of scope
  • 18. With DashProfiler Name of profile created with add_profile() package MyNetIO; use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ]; sub send_request { my ($hostname, $request) = @_ my $sample = foo_profiler( $hostname ); ...send to $hostname... } Duration is measured when $sample goes out of scope
  • 19. With DashProfiler Name of profile created with add_profile() Value to use for ‘key1’ package MyNetIO; use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ]; sub send_request { my ($hostname, $request) = @_ my $sample = foo_profiler( $hostname ); ...send to $hostname... } Duration is measured when $sample goes out of scope
  • 20. With DashProfiler Name of profile created with add_profile() Value to use for ‘key1’ package MyNetIO; use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ]; sub send_request { Value to use for ‘key2’ my ($hostname, $request) = @_ my $sample = foo_profiler( $hostname ); ...send to $hostname... } Duration is measured when $sample goes out of scope
  • 21. With DashProfiler package MyNetIO; use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ]; sub send_request { my ($hostname, $request) = @_ my $sample = foo_profiler( $hostname ) if foo_profiler_enabled(); ...send to $hostname... }
  • 22. With DashProfiler package MyNetIO; use DashProfiler::Import foo_profiler => [ ‘MyNetIO’ ]; sub send_request { my ($hostname, $request) = @_ my $sample = foo_profiler( $hostname ) if foo_profiler_enabled(); ...send to $hostname... Automatically imported compile-time constant } reduces cost to zero if profile is disabled
  • 23. DashProfiler Flush Data is written to STDERR on exit, by default Regular flushing is enabled by specifying a flush_interval The dbi_profile_class handles the flush. Choices include: DBI::Profile DBI::ProfileData DBI::ProfileData::Apache DashProfiler->add_profile( foo => { ..., flush_interval => 600, dbi_profile_class => ‘DBI::ProfileData’, flush_hook => sub { ... }, ... });
  • 24. DashProfiler Periods • Group samples into periods - e.g. http request to response - start_sample_period() and end_sample_period() - counted, to enable averages and totals per period - can output period counts instead of sample counts • Measure ‘exclusive’ time - time from period start to end that’s not been accounted for by other samples - enabled via period_exclusive option
  • 25. Example Data Average response times over 24 hours DashProfiler doesn’t generate graphs itself, but the data can be used to create graphs like these
  • 26. Example Data Worst case response times over 24 hours
  • 27.
  • 28. DashProfiler Perspectives • Each DashProfiler can have multiple DBI Profile objects attached • Samples accumulate in all attached profiles • Each profile can have a different Path • giving different ‘perspectives’ or level of detail - key1 + key2 - key1 + country + browser type - key2 + browser type - ... etc.
  • 29.
  • 30. DashProfiler Per-Period • Optional extra ‘per-period’ DBI profile • Enabled via period_summary option • Automatically attached and reset by start_sample_period() • Gives current totals for this period • Great for ‘debug footers’ on web page showing how much time was spent generating this page
  • 32. DashProfiler Cost Time cost of taking a sample: 0.000022s
  • 33.

Notes de l'éditeur

  1. Still need to write code to flush
  2. Still need to write code to flush
  3. Still need to write code to flush
  4. Still need to write code to flush
  5. First sample populates all Later samples always update 0, 1, and 6 and may update 3 or 4
  6. Create named profiles Lots of features
  7. DashProfiler::Import imports a pre-curried profiler code ref Profilers return bless object containing timestamp Object destruction triggers accumulation of sample
  8. Time to create sample object, destroy it, accumulate the counts In hot code can be 0.000017s C version of sampler class should more than half the cost
  9. Time to create sample object, destroy it, accumulate the counts In hot code can be 0.000017s C version of sampler class should more than half the cost