SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Phorum MySQL tricks
Phorum MySQL tricksPhorum MySQL tricks
Phorum MySQL tricksguestd34230
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisationgrooverdan
 
Nginx Scalable Stack
Nginx Scalable StackNginx Scalable Stack
Nginx Scalable StackBruno Paiuca
 
Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019Katie Sylor-Miller
 
Memcached Presentation
Memcached PresentationMemcached Presentation
Memcached PresentationAsif Ali
 
From One to a Cluster
From One to a ClusterFrom One to a Cluster
From One to a Clusterguestd34230
 
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)Ontico
 
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
 
Django and Nginx reverse proxy cache
Django and Nginx reverse proxy cacheDjango and Nginx reverse proxy cache
Django and Nginx reverse proxy cacheAnton Pirker
 
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.comIlya Grigorik
 
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 AnalysisFastly
 
WordPress Need For Speed
WordPress Need For SpeedWordPress Need For Speed
WordPress Need For Speedpdeschen
 
Xdebug, KCacheGrind and Webgrind with WampServer
Xdebug, KCacheGrind and Webgrind with WampServer  Xdebug, KCacheGrind and Webgrind with WampServer
Xdebug, KCacheGrind and Webgrind with WampServer Mediovski Technology
 
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 1Hamidreza Soleimani
 

Was ist angesagt? (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
 

Ähnlich wie Introduction to performance tuning perl web applications

Clug 2012 March web server optimisation
Clug 2012 March   web server optimisationClug 2012 March   web server optimisation
Clug 2012 March web server optimisationgrooverdan
 
Scalable Apache for Beginners
Scalable Apache for BeginnersScalable Apache for Beginners
Scalable Apache for Beginnerswebhostingguy
 
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)Artem Orobets
 
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 MeetupStrangeloop
 
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, Александр Крижа...Ontico
 
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!MongoDB
 
Full Stack Load Testing
Full Stack Load Testing Full Stack Load Testing
Full Stack Load Testing Terral R Jordan
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with MicronautQAware GmbH
 
Web performance mercadolibre - ECI 2013
Web performance   mercadolibre - ECI 2013Web performance   mercadolibre - ECI 2013
Web performance mercadolibre - ECI 2013Santiago Aimetta
 
Writing Java Serverless Application Using Micronaut
Writing Java Serverless Application Using MicronautWriting Java Serverless Application Using Micronaut
Writing Java Serverless Application Using MicronautAndrew Zakordonets
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceArjan
 
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.pptTricantinoLopezPerez
 
Cloud Performance Benchmarking
Cloud Performance BenchmarkingCloud Performance Benchmarking
Cloud Performance BenchmarkingSantanu Dey
 
Performance in business terms
Performance in business termsPerformance in business terms
Performance in business termsStrangeloop
 
Site Speed Fundamentals
Site Speed FundamentalsSite Speed Fundamentals
Site Speed FundamentalsMartin Breest
 
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 InstanceScyllaDB
 
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 applicationsGraham Dumpleton
 

Ähnlich wie 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
 

Mehr von Perrin Harkins

Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notesPerrin Harkins
 
Low maintenance perl notes
Low maintenance perl notesLow maintenance perl notes
Low maintenance perl notesPerrin Harkins
 
Choosing a Web Architecture for Perl
Choosing a Web Architecture for PerlChoosing a Web Architecture for Perl
Choosing a Web Architecture for PerlPerrin Harkins
 
Efficient Shared Data in Perl
Efficient Shared Data in PerlEfficient Shared Data in Perl
Efficient Shared Data in PerlPerrin Harkins
 
Choosing a Templating System
Choosing a Templating SystemChoosing a Templating System
Choosing a Templating SystemPerrin Harkins
 
Scaling Databases with DBIx::Router
Scaling Databases with DBIx::RouterScaling Databases with DBIx::Router
Scaling Databases with DBIx::RouterPerrin Harkins
 
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 ApplicationsPerrin Harkins
 
Top 10 Perl Performance Tips
Top 10 Perl Performance TipsTop 10 Perl Performance Tips
Top 10 Perl Performance TipsPerrin Harkins
 
The Most Common Template Toolkit Mistake
The Most Common Template Toolkit MistakeThe Most Common Template Toolkit Mistake
The Most Common Template Toolkit MistakePerrin Harkins
 

Mehr von 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
 

Kürzlich hochgeladen

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Kürzlich hochgeladen (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

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