SlideShare une entreprise Scribd logo
1  sur  61
Télécharger pour lire hors ligne
CACHING FOR CASH -
   BENCHMARKING
Scott MacVicar + Helgi Þormar Þorbjörnsson
             php|works 2008
GOALS



Learn how to find slow pages

Locate slow blocks of code

Apply minor optimisations
THOUGHT STEPS



Things seem a bit slow

Take a guess whats slow

Browse lots of code
SYSTEM COMPONENTS


Appliation Server

Database Server

Application

Database

Network
PAGE BENCHMARKING



Single Request doesn’t matter

Average time for maximum amount of users

Hopefully at worst it scales linearly
REQUIREMENTS


Same hardware configuration

Same server configuration

Same network interface speed (100mbps)

Basically your “staging server”
STEPS TO BENCHMARK



Record server load

Run our tests at least 3 times

Take average of tests
BENCHMARKING TOOLS



Apache Bench

Apache Flood

Siege
APACHE BENCH


Shows requests per
second

Bundled with Apache

Gives relative idea of
load
APACHE BENCH - DEMO

1000 Requests with 5 at a time
ab -n 1000 -c 5 http://localhost/phpBB3/index.php

1000 requests with 5 at a time using keep alive
ab -n 1000 -c 5 -k http://localhost/phpBB3/index.php

Output results to Excel / GNUPlot
ab -n 1000 -c 5 -g http://localhost/phpBB3/index.php
ISSUES WITH APACHE BENCH



Synthetic Benchmark

No way to emulate users
APACHE FLOOD



Profile driven
benchmarking

XML Based config

Use variables on pages
XML FORMAT


URLLIST

FARM

FARMER

PROFILE
URLIST



Simple group of URLs

Supports postdelay and predelay
FARMER


Single User

Can use URLLIST in various ways

  Random Order

  Round Robin

  Keep-Alive
FARM



It’s where the farmers work

Controls the way the farmers work

Creates farmers too
PROFILE


Runtime configuration

Can change various settings

  socket

  report
USE CASES



User visits main page

User visits main page then download page

User visits main page then download and downloads
a file
SINGLE PAGE


                Keep Alive
 Page   Image                Image
SINGLE PAGE XML
TWO PAGE VISITS


                       Keep Alive
   Page        Image                Image

     30 secs
      later

                       Keep Alive
   Page        Image                Image
TWO PAGE VISITS XML
TWO PAGE VISITS AND
   DOWNOAD
                         Keep Alive
     Page        Image                Image

       30 secs
        later

                         Keep Alive
     Page        Image                Image

       15 secs
        later


     ISO
TWO PAGE VISIT AND
 DOWNOAD XML
SETUP A PROFILE



enable keepalive

use the relative times output format

check for 200 OK
PROFILE XML
JOE THE FARMER
FARM FOR JOE TO WORK ON
RUNNING FLOOD



flood <configuration.xml> > output.file

anaylze-relative output.file
VMWARE INSTALL


                                                         Run
     Run VMware-                                      VMware-
                        Run VMWare-fusion.dmg
player-2.5.0-118166.exe                       Player-2.5.0-118166.i386
                                                       .bundle

                               Reboot

                    Copy Fedora 10 Folder to Disk
                          Load via VMWare
                           php / password
TASK
• Visit http://localhost/phpBB3/
• View a forum after 20 seconds
• View a thread after 5 seconds
• Click reply after 60 seconds
• Sample file in flood-examples folder
SIEGE



Provides functionality of Apache Bench and Flood

Supports GET and POST with a simple syntax

Benchmark and Internet mode
SIEGE COMMANDS

1000 Requests with 5 at a time
siege -b -r 1000 -c 5 http://localhost/phpBB3/index.php

10 seconds with concurrency of 5
siege -b -c 5 -t 10 http://localhost/phpBB3/index.php

Read urls.txt for a list of URLs
siege -b -n 1000 -c 5
SPROXY


Creates local socks proxy on your machine

Set your browser to use the local proxy, port 9001

Browse your site with the actions you wish

urls.txt is written with the POST and GET data
OTHER BENCHMARKING
         TOOLS


JMeter

httperf

Web Application Stress Tool

OpenWebLoad
PROFILING
WHAT IS PROFILING


Examines the performance characteristics

Records every function call

Tracks execution time

Tracks memory usage
PROFILING TOOLS



XDebug

apd
XDEBUG



Debugger

Code Coverage

Memory and Executon time
XDEBUG PROTECTIONS



Stack overflow in PHP

Infinite Recursion
ERROR MESSAGE HELPING
XDEBUG HELPFUL ERROR
     MESSAGES
MORE ERROR MESSAGE
     HELPING
EXECUTION TIME
MEMORY USAGE
EXECUTION TRACE


xdebug.auto_trace=1

xdebug.trace_output_dir=/tmp

xdebug.collect_params=1

xdebug.collect_return=1

xdebug.trace_output_name=trace.%c
EXECUTION TRACE
PARTIAL EXECUTION TRACE

Tracing only parts of an application with
xdebug_start_trace() and xdebug_stop_trace().

Fetching the trace file name that is being used with
xdebug_get_tracefile_name().

Changing how much data is shown with
xdebug.var_display_max_children,
xdebug.var_display_max_data and
xdebug.var_display_max_depth.
CODE COVERAGE


Finds unexecuted code

xdebug_start_code_coverage()

xdebug_get_code_coverage()

xdebug_stop_code_coverage()
CODE COVERAGE SAMPLE
CODE COVERAGE OUTPUT
PROFILING


Execute action as normal in browser

Outputs cachegrind file

INI settings:
xdebug.profiler_enable=1 ; enable profiler
xdebug.profile_output_dir=/tmp ; output directory
xdebug.profile_output_name=cachegrind.out.%p
PROFILING CONTINUED


Locate parts of the code that is slow

Work down tree to find the slow sections

Can it be cached? Can it be optimized?

Occasionally built?
VIEWING PROFILE


KCacheGrind

MacCallGrind

WinCacheGrind

Carica CacheGrind
PROFILING DEMO
TASK

sudo nano -w /etc/php.d/xdebug.ini
remove ; from xdebug.profiler_enabled=1

Profile a page on Wordpress

Profile a page on phpBB

Try to find something slow you think could be
improved

20 minutes
APD


Lives in PECL

Similar to XDebug

Doesn’t require KCachegrind

Still only PHP 4
APD



apd_set_pprof_trace() to enable profiler

pprof is a script to interpret the trace

Outputs to apd.dumpdir
BRINGING IT TOGETHER



Use profiler with benchmarks

Profiling can be run on production sites

Optimise slow code
RESOURCES


Lunch - back at 1pm for Caching

http://talks.macvicar.net/

http://httpd.apache.org/test/flood/

http://xdebug.org/docs/

http://www.joedog.org

Contenu connexe

Tendances

플랫폼 통합을 위한 Client Module 개발 & 배포
플랫폼 통합을 위한 Client Module 개발 & 배포플랫폼 통합을 위한 Client Module 개발 & 배포
플랫폼 통합을 위한 Client Module 개발 & 배포
흥래 김
 
Aeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filteringAeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filtering
Conrad Cruz
 
Aeon mike guide transparent ssl filtering (1)
Aeon mike guide transparent ssl filtering (1)Aeon mike guide transparent ssl filtering (1)
Aeon mike guide transparent ssl filtering (1)
Conrad Cruz
 
Scripting Yor Java Application with BSF3
Scripting Yor Java Application with BSF3Scripting Yor Java Application with BSF3
Scripting Yor Java Application with BSF3
day
 
Itb2018 cf apps to dev to production with command box cf-config docker
Itb2018   cf apps to dev to production with command box cf-config dockerItb2018   cf apps to dev to production with command box cf-config docker
Itb2018 cf apps to dev to production with command box cf-config docker
Ortus Solutions, Corp
 

Tendances (20)

How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
 
High Performance Web Sites
High Performance Web SitesHigh Performance Web Sites
High Performance Web Sites
 
Nginx [engine x] and you (and WordPress)
Nginx [engine x] and you (and WordPress)Nginx [engine x] and you (and WordPress)
Nginx [engine x] and you (and WordPress)
 
EasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on NginxEasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on Nginx
 
Memcached B box presentation
Memcached B box presentationMemcached B box presentation
Memcached B box presentation
 
Caching Data For Performance
Caching Data For PerformanceCaching Data For Performance
Caching Data For Performance
 
Apache
ApacheApache
Apache
 
Apache
ApacheApache
Apache
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
플랫폼 통합을 위한 Client Module 개발 & 배포
플랫폼 통합을 위한 Client Module 개발 & 배포플랫폼 통합을 위한 Client Module 개발 & 배포
플랫폼 통합을 위한 Client Module 개발 & 배포
 
Performance all teh things
Performance all teh thingsPerformance all teh things
Performance all teh things
 
Optimizing WordPress for Performance - WordCamp Houston
Optimizing WordPress for Performance - WordCamp HoustonOptimizing WordPress for Performance - WordCamp Houston
Optimizing WordPress for Performance - WordCamp Houston
 
Aeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filteringAeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filtering
 
Aeon mike guide transparent ssl filtering (1)
Aeon mike guide transparent ssl filtering (1)Aeon mike guide transparent ssl filtering (1)
Aeon mike guide transparent ssl filtering (1)
 
Scripting Yor Java Application with BSF3
Scripting Yor Java Application with BSF3Scripting Yor Java Application with BSF3
Scripting Yor Java Application with BSF3
 
Magento caching
Magento cachingMagento caching
Magento caching
 
Watch Me Install Alfresco
Watch Me Install AlfrescoWatch Me Install Alfresco
Watch Me Install Alfresco
 
grate techniques
grate techniquesgrate techniques
grate techniques
 
Itb2018 cf apps to dev to production with command box cf-config docker
Itb2018   cf apps to dev to production with command box cf-config dockerItb2018   cf apps to dev to production with command box cf-config docker
Itb2018 cf apps to dev to production with command box cf-config docker
 
Compcon 2016 Workshop
Compcon 2016 WorkshopCompcon 2016 Workshop
Compcon 2016 Workshop
 

Similaire à Caching for Cash: Benchmarking and Profiling

Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Joseph Scott
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
Fabien Potencier
 

Similaire à Caching for Cash: Benchmarking and Profiling (20)

The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
infra-as-code
infra-as-codeinfra-as-code
infra-as-code
 
Into The Box 2018 Ortus Keynote
Into The Box 2018 Ortus KeynoteInto The Box 2018 Ortus Keynote
Into The Box 2018 Ortus Keynote
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
Automation day red hat ansible
   Automation day red hat ansible    Automation day red hat ansible
Automation day red hat ansible
 
Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and Symfony
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on Steroids
 
Automação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOpsAutomação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOps
 
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
 
A rough guide to JavaScript Performance
A rough guide to JavaScript PerformanceA rough guide to JavaScript Performance
A rough guide to JavaScript Performance
 
Improve your Java Environment with Docker
Improve your Java Environment with DockerImprove your Java Environment with Docker
Improve your Java Environment with Docker
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 
ApacheConNA 2015: What's new in Apache httpd 2.4
ApacheConNA 2015: What's new in Apache httpd 2.4ApacheConNA 2015: What's new in Apache httpd 2.4
ApacheConNA 2015: What's new in Apache httpd 2.4
 
Apache httpd 2.4 overview
Apache httpd 2.4 overviewApache httpd 2.4 overview
Apache httpd 2.4 overview
 
Practical solutions for connections administrators
Practical solutions for connections administratorsPractical solutions for connections administrators
Practical solutions for connections administrators
 
Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]
 
Word press, the automated way
Word press, the automated wayWord press, the automated way
Word press, the automated way
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 

Plus de Scott MacVicar (6)

Alternative Databases
Alternative DatabasesAlternative Databases
Alternative Databases
 
PHP 5.3 + Windows
PHP 5.3 + WindowsPHP 5.3 + Windows
PHP 5.3 + Windows
 
PHP 5.3
PHP 5.3PHP 5.3
PHP 5.3
 
Alternative Databases
Alternative DatabasesAlternative Databases
Alternative Databases
 
How to write PHPT tests
How to write PHPT testsHow to write PHPT tests
How to write PHPT tests
 
SQLite 3
SQLite 3SQLite 3
SQLite 3
 

Dernier

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

Caching for Cash: Benchmarking and Profiling