SlideShare a Scribd company logo
1 of 35
Download to read offline
Introduction to
 Performance Tuning
Perl Web Applications
      Perrin Harkins
Find someone to
     blame
Performance vs scalability




● Not really the same thing
● Can look the same
● We're mostly going to talk about
  performance
Slowness




● Maybe it's the designer's fault!
● Chrome Developer Tools
Network
PageSpeed
Narrow it down
    further
Create a repeatable test



● Measure progress
● Metrics
  ○ Requests/second
  ○ Time for n requests
  ○ Concurrency
ab




ab -c1 -n100 http://127.0.0.1:8080/bugzilla/buglist.cgi
Benchmarking 127.0.0.1 (be patient).....done



Server Software:     Apache/2.2.22
Server Hostname:     127.0.0.1
Server Port:         8080

Document Path:       /bugzilla/buglist.cgi
Document Length:     14562 bytes

Concurrency Level:    1
Time taken for tests:    33.816 seconds
Complete requests:    100
Failed requests:      0
Write errors:         0
Total transferred:    1494100 bytes
HTML transferred:     1456200 bytes
Requests per second: 2.96 [#/sec] (mean)
Time per request:     338.163 [ms] (mean)
Time per request:     338.163 [ms] (mean, across all concurrent
requests)
Transfer rate:        43.15 [Kbytes/sec] received
Connection Times (ms)
             min mean[+/-sd]   median  max
Connect:     0    0   0.0      0   0
Processing:    313 338 20.7    333 448
Waiting:     312 337 20.6      332 448
Total:       313 338 20.7      333 448

Percentage of the requests served within a certain time (ms)
  50%    333
  66%    339
  75%    343
  80%    345
  90%    357
  95%    374
  98%    430
  99%    448
 100%    448 (longest request)
httperf




httperf --wsess=10,5,2 --rate=1 
     --server=localhost --port=8080 
     --uri=/bugzilla/buglist.cgi
Total: connections 50 requests 90 replies 50 test-duration 21.680 s

Connection rate: 2.3 conn/s (433.6 ms/conn, <=11 concurrent
connections)
Connection time [ms]: min 321.5 avg 2487.2 max 3884.7 median 2537.5
stddev 1002.1
Connection time [ms]: connect 0.1
Connection length [replies/conn]: 1.000

Request rate: 4.2 req/s (240.9 ms/req)
Request size [B]: 203.0

Reply rate [replies/s]: min 1.6 avg 2.4 max 3.0 stddev 0.6 (4
samples)
Reply time [ms]: response 883.0 transfer 3.4
Reply size [B]: header 388.0 content 14562.0 footer 2.0 (total
14952.0)
Reply status: 1xx=0 2xx=50 3xx=0 4xx=0 5xx=0

Session rate [sess/s]: min 0.00 avg 0.46 max 1.00 stddev 0.49 (10/10)
Session: avg 5.00 connections/session
Session lifetime [s]: 12.4
HTTP::Recorder




● Acts as HTTP proxy
● Generates Mechanize script
● HTTP::Recorder::Httperf
$agent->get('http://127.0.0.1:8080/bugzilla/');
$agent->follow_link(text => 'Search', n => '1');
$agent->form_name('queryform');
$agent->field('bug_status', '__open__');
$agent->field('content', '');
$agent->field('product', 'TestProduct');
$agent->click();
/bugzilla/ method=GET
    /bugzilla/skins/standard/global.css method=GET
    /bugzilla/skins/standard/index.css method=GET
    /bugzilla/skins/contrib/Dusk/global.css method=GET
    /bugzilla/skins/contrib/Dusk/index.css method=GET
    /bugzilla/js/yui/yahoo-dom-event/yahoo-dom-event.js method=GET
    /bugzilla/js/yui/cookie/cookie-min.js method=GET
    /bugzilla/js/global.js method=GET
    /bugzilla/skins/standard/index/file-a-bug.png method=GET
    /bugzilla/skins/standard/index/search.png method=GET
    /bugzilla/skins/standard/index/new-account.png method=GET
/bugzilla/query.cgi method=GET think=4
    /bugzilla/skins/standard/search_form.css method=GET
/bugzilla/buglist.cgi?
query_format=specific&order=relevance+desc&bug_status=__open__&produc
t=TestProduct&content= method=GET think=6
    /bugzilla/js/yui/assets/skins/sam/autocomplete.css method=GET
    /bugzilla/js/yui/assets/skins/sam/calendar.css method=GET
    /bugzilla/skins/standard/buglist.css method=GET
    /bugzilla/skins/contrib/Dusk/buglist.css method=GET
Autobench
Profile to find out where the
             time is going



● Devel::NYTProf
● Wall clock time vs. CPU time
● Use your real environment
● Multiple runs and warmup avoid
  skewed results
● Let's look at one...
Ten bucks says it's
  your database
Sure, every now and then you
             find


●   A bad regex
●   A string being parsed over and over
●   Massive object instantiation
●   Network operations
●   Disk reads
But mostly it's the database



● What’s slow in modern computers?
● What does most of the I/O in a typical
  web app?
● Either fix your queries or cache them
Profiling DBI




● DBI_PROFILE=2/DBI::ProfileDumper::Apache
● Let's look at one...
Speeding up queries



● EXPLAIN plans
  ○ pt-query-advisor
● SQL generation is not for everything
● A little bit of database server tuning
  ○ pt-variable-advisor
Speeding up DBI




● Cache connections and statements
● Manage commits
● Use native bulk loading tools
The last resort: caching


● Cache management is a hard problem
● Code complexity
  ○ invalidation calls
  ○ dependency tracking
● Your content creators will hate it
● When you do cache, use CHI
A brief word about runtime
         environments


● Webserver choice has a minimal effect
  on performance
● Persistent daemon: mod_perl, Plack,
  FastCGI
● Buffer your output
● Size-limiting or auto restarts
Real-world pressures
Flailing



● Changing things based on guesses
  rather than data
● No QA
● Lots of collateral damage
● Emergency profiling
Benchmark::Stopwatch


my $stopwatch = Benchmark::Stopwatch->new->start;
...
$stopwatch->lap('load objects');
...
$stopwatch->lap('render template');
...
$stopwatch->lap('send response');

print $stopwatch->stop->summary;
Benchmark::Stopwatch




NAME               TIME     CUMULATIVE   PERCENTAGE
 load objects       1.000    1.000        14.289%
 render template    3.000    4.001        42.853%
 send response      2.000    6.001        28.572%
 _stop_             1.000    7.001        14.287%
Doubts about infrastructure



● “You're still using Foobar 1.5?! That’s
  so slow!”
● Keep your head
● Get help: FAQ, Google, mailing list/IRC
Buying hardware



● Good idea!
● A boatload of RAM hides a multitude of
  sins
● Make sure you know what the
  bottleneck is
Further reading




● Tim Bunce's Advanced DBI slides on
  CPAN
● Percona Toolkit
Thank you!
Introduction to performance tuning perl web applications

More Related Content

What's hot

Phorum MySQL tricks
Phorum MySQL tricksPhorum MySQL tricks
Phorum MySQL tricks
guestd34230
 
From One to a Cluster
From One to a ClusterFrom One to a Cluster
From One to a Cluster
guestd34230
 

What's hot (20)

Nginx + PHP
Nginx + PHPNginx + PHP
Nginx + PHP
 
Phorum MySQL tricks
Phorum MySQL tricksPhorum MySQL tricks
Phorum MySQL tricks
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisation
 
Nginx Scalable Stack
Nginx Scalable StackNginx Scalable Stack
Nginx Scalable Stack
 
Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019
 
Memcached Presentation
Memcached PresentationMemcached Presentation
Memcached Presentation
 
From One to a Cluster
From One to a ClusterFrom One to a Cluster
From One to a Cluster
 
On Centralizing Logs
On Centralizing LogsOn Centralizing Logs
On Centralizing Logs
 
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
 
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
 
Tuning Solr for Logs
Tuning Solr for LogsTuning Solr for Logs
Tuning Solr for Logs
 
Web::Scraper
Web::ScraperWeb::Scraper
Web::Scraper
 
Django and Nginx reverse proxy cache
Django and Nginx reverse proxy cacheDjango and Nginx reverse proxy cache
Django and Nginx reverse proxy cache
 
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comRuby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
Compressing & decompressing in mule
Compressing & decompressing in muleCompressing & decompressing in mule
Compressing & decompressing in mule
 
Top Node.js Metrics to Watch
Top Node.js Metrics to WatchTop Node.js Metrics to Watch
Top Node.js Metrics to Watch
 
WordPress Need For Speed
WordPress Need For SpeedWordPress Need For Speed
WordPress Need For Speed
 
Xdebug, KCacheGrind and Webgrind with WampServer
Xdebug, KCacheGrind and Webgrind with WampServer  Xdebug, KCacheGrind and Webgrind with WampServer
Xdebug, KCacheGrind and Webgrind with WampServer
 
Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1
 

Similar to Introduction to performance tuning perl web applications

Scalable Apache for Beginners
Scalable Apache for BeginnersScalable Apache for Beginners
Scalable Apache for Beginners
webhostingguy
 
Oracle Wait Events That Everyone Should Know.ppt
Oracle Wait Events That Everyone Should Know.pptOracle Wait Events That Everyone Should Know.ppt
Oracle Wait Events That Everyone Should Know.ppt
TricantinoLopezPerez
 

Similar to Introduction to performance tuning perl web applications (20)

Http2 in practice
Http2 in practiceHttp2 in practice
Http2 in practice
 
Clug 2012 March web server optimisation
Clug 2012 March   web server optimisationClug 2012 March   web server optimisation
Clug 2012 March web server optimisation
 
Scalable Apache for Beginners
Scalable Apache for BeginnersScalable Apache for Beginners
Scalable Apache for Beginners
 
On the way to low latency (2nd edition)
On the way to low latency (2nd edition)On the way to low latency (2nd edition)
On the way to low latency (2nd edition)
 
From LAMP to LNNP
From LAMP to LNNPFrom LAMP to LNNP
From LAMP to LNNP
 
Web Performance Automation - NY Web Performance Meetup
Web Performance Automation - NY Web Performance MeetupWeb Performance Automation - NY Web Performance Meetup
Web Performance Automation - NY Web Performance Meetup
 
Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...
Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...
Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...
 
MongoDB .local Bengaluru 2019: Becoming an Ops Manager Backup Superhero!
MongoDB .local Bengaluru 2019: Becoming an Ops Manager Backup Superhero!MongoDB .local Bengaluru 2019: Becoming an Ops Manager Backup Superhero!
MongoDB .local Bengaluru 2019: Becoming an Ops Manager Backup Superhero!
 
Understanding
Understanding Understanding
Understanding
 
Full Stack Load Testing
Full Stack Load Testing Full Stack Load Testing
Full Stack Load Testing
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with Micronaut
 
Web performance mercadolibre - ECI 2013
Web performance   mercadolibre - ECI 2013Web performance   mercadolibre - ECI 2013
Web performance mercadolibre - ECI 2013
 
Writing Java Serverless Application Using Micronaut
Writing Java Serverless Application Using MicronautWriting Java Serverless Application Using Micronaut
Writing Java Serverless Application Using Micronaut
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & Performance
 
Oracle Wait Events That Everyone Should Know.ppt
Oracle Wait Events That Everyone Should Know.pptOracle Wait Events That Everyone Should Know.ppt
Oracle Wait Events That Everyone Should Know.ppt
 
Cloud Performance Benchmarking
Cloud Performance BenchmarkingCloud Performance Benchmarking
Cloud Performance Benchmarking
 
Performance in business terms
Performance in business termsPerformance in business terms
Performance in business terms
 
Site Speed Fundamentals
Site Speed FundamentalsSite Speed Fundamentals
Site Speed Fundamentals
 
Extreme HTTP Performance Tuning: 1.2M API req/s on a 4 vCPU EC2 Instance
Extreme HTTP Performance Tuning: 1.2M API req/s on a 4 vCPU EC2 InstanceExtreme HTTP Performance Tuning: 1.2M API req/s on a 4 vCPU EC2 Instance
Extreme HTTP Performance Tuning: 1.2M API req/s on a 4 vCPU EC2 Instance
 
PyCon HK 2015 - Monitoring the performance of python web applications
PyCon HK 2015 -  Monitoring the performance of python web applicationsPyCon HK 2015 -  Monitoring the performance of python web applications
PyCon HK 2015 - Monitoring the performance of python web applications
 

More from Perrin Harkins

More from Perrin Harkins (11)

Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notes
 
Scalable talk notes
Scalable talk notesScalable talk notes
Scalable talk notes
 
Low maintenance perl notes
Low maintenance perl notesLow maintenance perl notes
Low maintenance perl notes
 
Choosing a Web Architecture for Perl
Choosing a Web Architecture for PerlChoosing a Web Architecture for Perl
Choosing a Web Architecture for Perl
 
Efficient Shared Data in Perl
Efficient Shared Data in PerlEfficient Shared Data in Perl
Efficient Shared Data in Perl
 
Choosing a Templating System
Choosing a Templating SystemChoosing a Templating System
Choosing a Templating System
 
Scaling Databases with DBIx::Router
Scaling Databases with DBIx::RouterScaling Databases with DBIx::Router
Scaling Databases with DBIx::Router
 
Low-Maintenance Perl
Low-Maintenance PerlLow-Maintenance Perl
Low-Maintenance Perl
 
Care and Feeding of Large Web Applications
Care and Feeding of Large Web ApplicationsCare and Feeding of Large Web Applications
Care and Feeding of Large Web Applications
 
Top 10 Perl Performance Tips
Top 10 Perl Performance TipsTop 10 Perl Performance Tips
Top 10 Perl Performance Tips
 
The Most Common Template Toolkit Mistake
The Most Common Template Toolkit MistakeThe Most Common Template Toolkit Mistake
The Most Common Template Toolkit Mistake
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 

Introduction to performance tuning perl web applications

  • 1. Introduction to Performance Tuning Perl Web Applications Perrin Harkins
  • 3. Performance vs scalability ● Not really the same thing ● Can look the same ● We're mostly going to talk about performance
  • 4. Slowness ● Maybe it's the designer's fault! ● Chrome Developer Tools
  • 7. Narrow it down further
  • 8. Create a repeatable test ● Measure progress ● Metrics ○ Requests/second ○ Time for n requests ○ Concurrency
  • 9. ab ab -c1 -n100 http://127.0.0.1:8080/bugzilla/buglist.cgi
  • 10. Benchmarking 127.0.0.1 (be patient).....done Server Software: Apache/2.2.22 Server Hostname: 127.0.0.1 Server Port: 8080 Document Path: /bugzilla/buglist.cgi Document Length: 14562 bytes Concurrency Level: 1 Time taken for tests: 33.816 seconds Complete requests: 100 Failed requests: 0 Write errors: 0 Total transferred: 1494100 bytes HTML transferred: 1456200 bytes Requests per second: 2.96 [#/sec] (mean) Time per request: 338.163 [ms] (mean) Time per request: 338.163 [ms] (mean, across all concurrent requests) Transfer rate: 43.15 [Kbytes/sec] received
  • 11. Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 313 338 20.7 333 448 Waiting: 312 337 20.6 332 448 Total: 313 338 20.7 333 448 Percentage of the requests served within a certain time (ms) 50% 333 66% 339 75% 343 80% 345 90% 357 95% 374 98% 430 99% 448 100% 448 (longest request)
  • 12. httperf httperf --wsess=10,5,2 --rate=1 --server=localhost --port=8080 --uri=/bugzilla/buglist.cgi
  • 13. Total: connections 50 requests 90 replies 50 test-duration 21.680 s Connection rate: 2.3 conn/s (433.6 ms/conn, <=11 concurrent connections) Connection time [ms]: min 321.5 avg 2487.2 max 3884.7 median 2537.5 stddev 1002.1 Connection time [ms]: connect 0.1 Connection length [replies/conn]: 1.000 Request rate: 4.2 req/s (240.9 ms/req) Request size [B]: 203.0 Reply rate [replies/s]: min 1.6 avg 2.4 max 3.0 stddev 0.6 (4 samples) Reply time [ms]: response 883.0 transfer 3.4 Reply size [B]: header 388.0 content 14562.0 footer 2.0 (total 14952.0) Reply status: 1xx=0 2xx=50 3xx=0 4xx=0 5xx=0 Session rate [sess/s]: min 0.00 avg 0.46 max 1.00 stddev 0.49 (10/10) Session: avg 5.00 connections/session Session lifetime [s]: 12.4
  • 14. HTTP::Recorder ● Acts as HTTP proxy ● Generates Mechanize script ● HTTP::Recorder::Httperf
  • 15. $agent->get('http://127.0.0.1:8080/bugzilla/'); $agent->follow_link(text => 'Search', n => '1'); $agent->form_name('queryform'); $agent->field('bug_status', '__open__'); $agent->field('content', ''); $agent->field('product', 'TestProduct'); $agent->click();
  • 16. /bugzilla/ method=GET /bugzilla/skins/standard/global.css method=GET /bugzilla/skins/standard/index.css method=GET /bugzilla/skins/contrib/Dusk/global.css method=GET /bugzilla/skins/contrib/Dusk/index.css method=GET /bugzilla/js/yui/yahoo-dom-event/yahoo-dom-event.js method=GET /bugzilla/js/yui/cookie/cookie-min.js method=GET /bugzilla/js/global.js method=GET /bugzilla/skins/standard/index/file-a-bug.png method=GET /bugzilla/skins/standard/index/search.png method=GET /bugzilla/skins/standard/index/new-account.png method=GET /bugzilla/query.cgi method=GET think=4 /bugzilla/skins/standard/search_form.css method=GET /bugzilla/buglist.cgi? query_format=specific&order=relevance+desc&bug_status=__open__&produc t=TestProduct&content= method=GET think=6 /bugzilla/js/yui/assets/skins/sam/autocomplete.css method=GET /bugzilla/js/yui/assets/skins/sam/calendar.css method=GET /bugzilla/skins/standard/buglist.css method=GET /bugzilla/skins/contrib/Dusk/buglist.css method=GET
  • 18. Profile to find out where the time is going ● Devel::NYTProf ● Wall clock time vs. CPU time ● Use your real environment ● Multiple runs and warmup avoid skewed results ● Let's look at one...
  • 19. Ten bucks says it's your database
  • 20. Sure, every now and then you find ● A bad regex ● A string being parsed over and over ● Massive object instantiation ● Network operations ● Disk reads
  • 21. But mostly it's the database ● What’s slow in modern computers? ● What does most of the I/O in a typical web app? ● Either fix your queries or cache them
  • 23. Speeding up queries ● EXPLAIN plans ○ pt-query-advisor ● SQL generation is not for everything ● A little bit of database server tuning ○ pt-variable-advisor
  • 24. Speeding up DBI ● Cache connections and statements ● Manage commits ● Use native bulk loading tools
  • 25. The last resort: caching ● Cache management is a hard problem ● Code complexity ○ invalidation calls ○ dependency tracking ● Your content creators will hate it ● When you do cache, use CHI
  • 26. A brief word about runtime environments ● Webserver choice has a minimal effect on performance ● Persistent daemon: mod_perl, Plack, FastCGI ● Buffer your output ● Size-limiting or auto restarts
  • 28. Flailing ● Changing things based on guesses rather than data ● No QA ● Lots of collateral damage ● Emergency profiling
  • 29. Benchmark::Stopwatch my $stopwatch = Benchmark::Stopwatch->new->start; ... $stopwatch->lap('load objects'); ... $stopwatch->lap('render template'); ... $stopwatch->lap('send response'); print $stopwatch->stop->summary;
  • 30. Benchmark::Stopwatch NAME TIME CUMULATIVE PERCENTAGE load objects 1.000 1.000 14.289% render template 3.000 4.001 42.853% send response 2.000 6.001 28.572% _stop_ 1.000 7.001 14.287%
  • 31. Doubts about infrastructure ● “You're still using Foobar 1.5?! That’s so slow!” ● Keep your head ● Get help: FAQ, Google, mailing list/IRC
  • 32. Buying hardware ● Good idea! ● A boatload of RAM hides a multitude of sins ● Make sure you know what the bottleneck is
  • 33. Further reading ● Tim Bunce's Advanced DBI slides on CPAN ● Percona Toolkit