SlideShare a Scribd company logo
Profiling PHP
             Applications


Sam Keen
@samkeen
pdxphp.org: May 2009 Meeting
Summary
•   Huge topic, so we will settle on one aspect
    of it
•   Concentrate on the Code aspect of
    profiling
•   We’ll concern ourselves more with ‘tools
    to get started’ rather than ‘Preferment
    code best practices’ (see last slide for that)
•   Will introduce a ‘secret ingredient’ that
    makes profiling super delicious!
The Scenario

You build a killer PHP site


Works great out of the gate
but then slowly degrades as
more people use it until...
Profiling PHP with Xdebug / Webgrind

Recommended for you

Martin Aspeli Extending And Customising Plone 3
Martin Aspeli   Extending And Customising Plone 3Martin Aspeli   Extending And Customising Plone 3
Martin Aspeli Extending And Customising Plone 3

This document discusses customizing and extending Plone 3 using buildout, eggs, GenericSetup profiles, and testing. Key points include: 1) Using buildout to manage dependencies and custom packages, including developing packages locally. 2) Creating a "policy product" that installs all customizations and dependencies in one step. 3) Customizing Plone through GenericSetup profiles using XML configuration files and custom import steps. 4) Writing tests to ensure customizations are properly installed and configured. 5) Customizing visual components like skins, views, and resources using layers and browser resources. Thorough testing and source control are emphasized.

Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask

A quick intro to using the Python micro framework Flask. Building a simple multiple page website from the ground up.

programmingpythonchattanooga
Xdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP codeXdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP code

In depth presentation on setting up, configuring, and trigger PHP Xdebug for step through debugging and code profiling. This presentation will not tell you how to configure your Xdebug client. It will help you understand how to configure and tune Xdebug for web and CLI based debugging and profiling in PHP.

profilingdebuggingxdebug
How do we avoid this

  Or at least lesson the chance of it happening or at a
minimum reduce the amount of “material” hitting the fan
                when it inevitably occurs
Profiling



                -       should be done during development
                -       allows you to spot inefficiencies and
                        bottlenecks in code rather than your
                        clients
Photo: http://www.flickr.com/photos/chermida/2913511936/
Facilitating Profiling
    During Development

•   Make it as easy as possible to set up and
    use
•   This way it can become part of your daily
    (OK, maybe weekly) routine.
Many Aspects of
   Profiling

   Code       Db

   System   Network
  CPU/RAM

Recommended for you

WebPagetest Power Users - Velocity 2014
WebPagetest Power Users - Velocity 2014WebPagetest Power Users - Velocity 2014
WebPagetest Power Users - Velocity 2014

Slides for my tutorial from Velocity 2014 on some of the more advanced features in WebPagetest. Video is available on Youtube: Part 1: http://youtu.be/6UeRMMI_IzI Part 2: http://youtu.be/euVYHee1f1M

Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI

How to improve your workflows via SSH gateway. Experts at WP Engine help you learn about how WordPress developers can make their work more efficient using WP-CLI via SSH gateway to improve workflows. On-demand webinar: https://hs.wpengine.com/webinar-improve-workflows-SSH-gateway

wp-clissh gatewaywordpress
Simple webapps with nginx, uwsgi emperor and bottle
Simple webapps with nginx, uwsgi emperor and bottleSimple webapps with nginx, uwsgi emperor and bottle
Simple webapps with nginx, uwsgi emperor and bottle

Bottle is a small microframework that lets you build simple python webapps in a few minutes. This talk will explain how to build simple webapp from scratch and configure your system to deploy many other apps concurrently with a rock solid and scalable setup.

uwsgiwebappnginx
First steps for Db and
        System/Network
Query logs: slow and index-less

top, vmstat, dstat
$ dstat




@see http://dag.wieers.com/home-made/dstat
Profiling Code
               -Baseline-
Before you make changes, you need to get some sort of
    baseline of the performance of the application

    Otherwise, you cannot measure improvement



      So start with profiling the site as a “whole”
Web Server
       Profiling Tools
                   Apache Bench
                   HTTP_load
                   Siege




Web Server
HTTP_Load
Install
wget http://www.acme.com/software/http_load/http_load-12mar2006.tar.gz
tar -xzf http_load-12mar2006.tar.gz
cd http_load-12mar2006/
make
sudo make install




@see eZ Publish article for coverage of the others: http://bit.ly/sKYha
http://ez.no/developer/articles/ez_publish_performance_optimization_part_1_of_3_introduction_and_benchmarking

Recommended for you

AppengineJS
AppengineJSAppengineJS
AppengineJS

This document summarizes JavaScript support on Google App Engine including frameworks like Rhino, Narwhal, Ringo, and JSGI/Jack that allow running JavaScript applications on App Engine. It also describes the AppengineJS stack which provides APIs for the App Engine datastore, memcache, and other services via CommonJS packages. Key features of AppengineJS include support for templating, HTML parsing, and the Nitro framework.

gtugjavascriptappengine
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)

WebSockets couples the performance and flexibility of TCP with the reach of HTTP Prediction: WebSockets will replace simple TCP as preferred underlying protocol. To see how Websockets are used in a popular HTML5-based remote access solution, by visiting the following URL: http://j.mp/1luquBQ

websocketscommunication protocolweb security
WebPagetest - Good, Bad & Ugly
WebPagetest - Good, Bad & UglyWebPagetest - Good, Bad & Ugly
WebPagetest - Good, Bad & Ugly

Presentation by @aaronpeters at Dutch Web Performance Meetup on August 22 2012. The presentation covers new stuff in WPT UI, the WPT API, scripting and hidden gems. Awesome tool, but also room for improvement.

web performance
HTTP_Load
After creating for URL file (simple txt file with list o URLs
(one per line) that will be randomly chosen from by
http_load)

The run something like: (runs for ten seconds, with five
parallel requests)


    $ http_load -parallel 5 -seconds 10 urls.txt
HTTP_Load
Output
$ http_load -parallel 5 -seconds 10 urls.txt
90 fetches, 5 max parallel, 805770 bytes, in 10 seconds
8953 mean bytes/connection
8.99999 fetches/sec, 80576.9 bytes/sec
msecs/connect: 241.704 mean, 958.418 max, 73.01 min
msecs/first-response: 252.075 mean, 1067.61 max, 83.833 min
HTTP response codes:
  code 200 -- 90
Xdebug Profiling
Far more than just a profiler:
  * stack traces and function traces in error messages with:
       o full parameter display for user defined functions
       o function name, file name and line indications
       o support for member functions
  * memory allocation
  * protection for infinite recursions
  * profiling information for PHP scripts
  * code coverage analysis
  * debug your scripts interactively with a debug client

@see xdebug.org
Xdebug Install
@see http://www.xdebug.org/docs/install

Install with pecl
sudo pecl install xdebug


Add this line to your php.ini
zend_extension=quot;/usr/local/php/modules/xdebug.soquot;

Recommended for you

Odoo development workflow with pip and virtualenv
Odoo development workflow with pip and virtualenvOdoo development workflow with pip and virtualenv
Odoo development workflow with pip and virtualenv

This document discusses tools for managing Python packages and environments like pip, virtualenv, and setuptools. It also describes how these tools can be used to install Odoo, addons, and their dependencies from source code or packages. Key points covered include creating isolated environments, installing dependencies, freezing requirements, packaging addons, and automatic discovery of installed packages.

odooodoo community association
Philipp Von Weitershausen Plone Age Mammoths, Sabers And Caveen Cant The...
Philipp Von Weitershausen   Plone Age  Mammoths, Sabers And Caveen   Cant The...Philipp Von Weitershausen   Plone Age  Mammoths, Sabers And Caveen   Cant The...
Philipp Von Weitershausen Plone Age Mammoths, Sabers And Caveen Cant The...

It is the last Plone age. The big and strong but lonely mammoth has led the way for eons. But now it is threatened by a pack of saber-tooth tigers who are quick, agile and work together. Can the friendly caveman save the mammoth and make piece with the sabers? Can Grok help making Zope and Plone more agile? Will Zope and the other web frameworks fall in love, and what do WSGI and Paste have to say about that? From the makers of "Zope on a Paste", coming this October, a comedy for the whole family (developers, integrators and newbiews). Rated PG-13.

20151229 wnmp & phalcon micro app - part I
20151229 wnmp & phalcon micro app - part I20151229 wnmp & phalcon micro app - part I
20151229 wnmp & phalcon micro app - part I

Nginx, PHP, and Phalcon were installed and configured on Windows to serve web applications. Nginx was set up as a web server with PHP enabled through FastCGI. PHP and nginx processes were configured as Windows services using winsw. Phalcon was installed as a PHP extension. Testing involved accessing a phpinfo.php file to confirm PHP and Phalcon were installed correctly. Potential errors addressed included missing Visual C++ runtime libraries.

nginxphalconwindows
Xdebug Configure
;##### START XDEBUG SECTION ######;
zend_extension=/usr/lib/php/extensions/xdebug.so
xdebug.remote_enable=on
xdebug.remote_handle=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.profiler_enable = 1
xdebug.profiler_output_name = cachegrind.out.%t-%s
xdebug.profiler_output_dir=quot;/Users/sam/grind-outquot;
;##### END XDEBUG SECTION ######;



http://www.xdebug.org/docs/all_settings#profiler_output_name
Xdebug Local Setup
php.ini@ -> /usr/local/php5/lib/php.ini.zenddebug
php.ini.xdebug
php.ini.xdebug.profile
php.ini.zenddebug


~/bin (in my PATH)
-rwxr-xr-x@   php-xdebug*
-rwxr-xr-x@   php-xdebug-profile*
-rwxr-xr-x@   php-zenddebug*


Contents of        php-xdebug-profile
#!/bin/sh
rm /usr/local/php5/lib/php.ini
ln -s /usr/local/php5/lib/php.ini.xdebug.profile /usr/local/php5/lib/php.ini
sudo apachectl restart


$ php-xdebug-profile
Now running php with Xdebug PROFILE: hurray for open source
Profiling a specific page
With Xdebug profiling enabled

Simply request the web page in question using browser

Look in your xdebug.profiler_output_dir for output
    cachegrind.out.1242152836-_Library_WebServer_Documents_persist_better_see_signups_php
Examine the output

•   Traditionally: Kcachegrind
•   Install on Linux, or Windows: easy
•   Install on OSX: #&^!*&^!!


•   The Kcachegrind UI...

Recommended for you

SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)

Intro talk on the Percona Toolkit, as set of tools for managing things DBAs and developers need to do with MySQL.

mysqlperconaintro
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018

More information about this HTTP caching talk can be found on https://feryn.eu/speaking/leverage-http-to-deliver-cacheable-websites-codemotion-rome-2018/

cachehttpphp
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018

Most of us are familiar with HTTP, but when it actually comes to creating cacheable web content, there is still a lot to be learned. In this presentation I will show you how to leverage specific mechanism to achieve a good hit rate without losing touch with some of the challenges of real-life web projects. Keywords: cache control, cache variations, conditional requests, stateful content, HTTP fragments, invalidation. The goals is to empower developers to control the behavior of reverse caching proxies like Varnish, Content Delivery Networks, or even browser cache, using the power of HTTP.

codemotion rome 2018
Profiling PHP with Xdebug / Webgrind
And the Secret
  Ingredient
Webgrind

Webgrind is an Xdebug profiling web frontend in PHP5

@see http://code.google.com/p/webgrind/

Simple Installation on any platform that can run
WebServer/PHP5 stack

and the UI...
Profiling PHP with Xdebug / Webgrind

Recommended for you

Zenoss: Buildout
Zenoss: BuildoutZenoss: Buildout
Zenoss: Buildout

Buildout is a system for creating repeatable environments using a Windows ini-style syntax. It allows for easy deployment of Zenoss via buildout commands. Buildout has become a standard for deploying Plone applications and the presenter hopes it will spread to other open source projects. While some prefer system packages for things like libraries, buildout is useful when exact versions or custom configurations are needed. The buildout described satisfies Zenoss dependencies by downloading packages and dependencies like Zope2, MySQL, and rrdtool and configuring the environment.

plonebuildoutzenoss
Release with confidence
Release with confidenceRelease with confidence
Release with confidence

This document discusses integrating test automation and code coverage for web service applications. It introduces Postman for calling web services and testing responses, and Jenkins for build automation and tracking test results over time. It then demonstrates setting up a test automation workflow using these tools on a sample Laravel application, including starting and stopping coverage collection, running tests from Postman and PHPUnit, and merging the results. Some best practices and philosophies around test automation and code coverage are also discussed.

jenkinscode coveragephp
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101

A complete guide of optimizing Magento performance systematically, including LAMP(Linux, Apache, MySQL, PHP) optimization, tuning inside Magento and useful tools.

performance optimizationmagento
Webgrind Install
Install (Typical WebApp install: put the folder in your webroot
and edit a config file)

 1. Download to your web root




 * edit config.php
 * be sure $storageDir is writable by web server
Extend UI
UI is HTML and js (jquery) so trivial to make changes
The victim
http://local.persist.com/could_improve/
BaseLine
$ http_load -parallel 5 -seconds 10 urls_could_improve.txt
1928 fetches, 5 max parallel, 1.92362e+07 bytes, in 10.0002 seconds
9977.27 mean bytes/connection
192.796 fetches/sec, 1.92358e+06 bytes/sec
msecs/connect: 0.456549 mean, 9.326 max, 0.055 min
msecs/first-response: 21.7894 mean, 599.711 max, 0.862 min
HTTP response codes:
  code 200 -- 1928




 *you would also be watching CPU and RAM with something like
 dstat during this test to determine if we are CPU and/or memory
 bound (see resources on last slide)

Recommended for you

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

The document discusses the new features of Apache HTTP Server version 2.4, including performance improvements through more efficient modules and data structures, enhanced configuration options, new modules for capabilities like Lua scripting and remote IP access, and improved proxy functionality for dynamic and cloud environments. Key areas covered are performance, configuration, new modules, and proxy features.

apachewebserver
High Performance Web Sites
High Performance Web SitesHigh Performance Web Sites
High Performance Web Sites

The document provides recommendations for optimizing performance of high traffic web applications, including tuning Apache settings like MaxClients, enabling caching and compression, optimizing MySQL settings like query caching and indexing, improving PHP configurations for errors, sessions and uploads, and using tools to monitor and test performance. It also outlines best practices for page loading like reducing HTTP requests and moving scripts to the bottom.

highperformanceweb
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro

The document provides tips and best practices for developing Joomla sites as part of a team. It discusses using version control like SVN or Git, following coding standards for naming conventions and formatting, and leveraging tools for code review and team development. Additional suggestions are given for debugging, moving sites, testing for injections, and speeding up sites through techniques like removing Mootools and using content delivery networks. The presenter encourages sharing ideas to improve Joomla development.

joomlajoomla day chicago 2011steven pignataro
Explore the output
 using WebGrind
Lots of MDB2 at
the top of the list
Static Candidate
   (no code)
Push Work to Client



Push all this work to the client
$('dd.note').each(function(i){
     $(this).html($(this).text().replace(/(eb)/ig,
        '<span style=quot;color:red;font-weight:800;quot;>$1</span>')
     );
});

Recommended for you

Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability

Caching has been a 'hot' topic for a few years. But caching takes more than merely taking data and putting it in a cache : the right caching techniques can improve performance and reduce load significantly. But we'll also look at some major pitfalls, showing that caching the wrong way can bring down your site. If you're looking for a clear explanation about various caching techniques and tools like Memcached, Nginx and Varnish, as well as ways to deploy them in an efficient way, this talk is for you.

cachingvarnishnginx
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP MeetupWeb Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup

I gave this talk on 4/27/11 at the Boston PHP Meetup Group. It covers both server side and client side optimizations, as well as monitoring tools and techniques.

phpweb developmentweb performance
What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24

Jim Jagielski presents an overview of new features and enhancements in Apache HTTP Server version 2.4, including configuration and runtime improvements, new modules and capabilities, cloud and proxy enhancements, performance increases, and support for HTTP/2. Key highlights include finer-grained configuration controls, new modules like mod_lua and mod_macro, improved proxy and load balancing functionality, better performance through optimizations and new MPMs like Event, and initial HTTP/2 support.

apacheopen source
Make Adjustments
•   Switch to PDO
    •   typically lean towards php built-ins that abstract a
        great deal of functionality (rather than libs built in
        php).

•   Use static (.htm) pages if we don’t need DB
    •   output buffer caching another alternative

•   Use js to ‘markup’ content
    •   fastest way a web server can do work is not to
        do it

        changes took about 40 min of work
Re-profile
$ http_load -parallel 5 -seconds 10 urls_better.txt
5008 fetches, 5 max parallel, 3.40076e+07 bytes, in 10.0003 seconds
6790.65 mean bytes/connection
500.785 fetches/sec, 3.40066e+06 bytes/sec
msecs/connect: 0.401153 mean, 9.334 max, 0.055 min
msecs/first-response: 8.39298 mean, 259.332 max, 0.141 min
HTTP response codes:
  code 200 -- 5008

Improvement
fetches/sec: ~250%
first-response: ~275%
Resources
Profiling articles form eZ Publish
  * http://ez.no/developer/articles/ez_publish_performance_optimization_part_1_of_3_introduction_and_benchmarking
  * http://ez.no/developer/articles/
ez_publish_performance_optimization_part_2_of_3_identifying_trouble_spots_by_debugging
  * http://ez.no/developer/articles/
ez_publish_performance_optimization_part_3_of_3_practical_cache_and_template_solutions

Profiling articles form IBM
  * http://www.ibm.com/developerworks/linux/library/l-tune-lamp-1/
  * http://www.ibm.com/developerworks/linux/library/l-tune-lamp-2.html
  * http://www.ibm.com/developerworks/library/l-tune-lamp-3.html

Excellent Open Source PHP IDE which utilizes Xdebug (step through, profile, code coverage)
 * http://www.netbeans.org/features/php/index.html

Profiling Presentation from core PHP folks
 * http://talks.php.net/index.php/Performance

More Related Content

What's hot

Nahlédněte za oponu VersionPressu
Nahlédněte za oponu VersionPressuNahlédněte za oponu VersionPressu
Nahlédněte za oponu VersionPressu
Jan Voracek
 
X-Debug in Php Storm
X-Debug in Php StormX-Debug in Php Storm
X-Debug in Php Storm
KLabCyscorpions-TechBlog
 
Autotests introduction - Codeception + PHP Basics
Autotests introduction - Codeception + PHP BasicsAutotests introduction - Codeception + PHP Basics
Autotests introduction - Codeception + PHP Basics
Artur Babyuk
 
Martin Aspeli Extending And Customising Plone 3
Martin Aspeli   Extending And Customising Plone 3Martin Aspeli   Extending And Customising Plone 3
Martin Aspeli Extending And Customising Plone 3
Vincenzo Barone
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
juzten
 
Xdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP codeXdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP code
Adam Englander
 
WebPagetest Power Users - Velocity 2014
WebPagetest Power Users - Velocity 2014WebPagetest Power Users - Velocity 2014
WebPagetest Power Users - Velocity 2014
Patrick Meenan
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI
WP Engine
 
Simple webapps with nginx, uwsgi emperor and bottle
Simple webapps with nginx, uwsgi emperor and bottleSimple webapps with nginx, uwsgi emperor and bottle
Simple webapps with nginx, uwsgi emperor and bottle
Jordi Soucheiron
 
AppengineJS
AppengineJSAppengineJS
AppengineJS
Panagiotis Astithas
 
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
Ericom Software
 
WebPagetest - Good, Bad & Ugly
WebPagetest - Good, Bad & UglyWebPagetest - Good, Bad & Ugly
WebPagetest - Good, Bad & Ugly
Aaron Peters
 
Odoo development workflow with pip and virtualenv
Odoo development workflow with pip and virtualenvOdoo development workflow with pip and virtualenv
Odoo development workflow with pip and virtualenv
acsone
 
Philipp Von Weitershausen Plone Age Mammoths, Sabers And Caveen Cant The...
Philipp Von Weitershausen   Plone Age  Mammoths, Sabers And Caveen   Cant The...Philipp Von Weitershausen   Plone Age  Mammoths, Sabers And Caveen   Cant The...
Philipp Von Weitershausen Plone Age Mammoths, Sabers And Caveen Cant The...
Vincenzo Barone
 
20151229 wnmp & phalcon micro app - part I
20151229 wnmp & phalcon micro app - part I20151229 wnmp & phalcon micro app - part I
20151229 wnmp & phalcon micro app - part I
Taien Wang
 
SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)
Robert Swisher
 
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Thijs Feryn
 
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Codemotion
 
Zenoss: Buildout
Zenoss: BuildoutZenoss: Buildout
Zenoss: Buildout
Jeffrey Clark
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
John Congdon
 

What's hot (20)

Nahlédněte za oponu VersionPressu
Nahlédněte za oponu VersionPressuNahlédněte za oponu VersionPressu
Nahlédněte za oponu VersionPressu
 
X-Debug in Php Storm
X-Debug in Php StormX-Debug in Php Storm
X-Debug in Php Storm
 
Autotests introduction - Codeception + PHP Basics
Autotests introduction - Codeception + PHP BasicsAutotests introduction - Codeception + PHP Basics
Autotests introduction - Codeception + PHP Basics
 
Martin Aspeli Extending And Customising Plone 3
Martin Aspeli   Extending And Customising Plone 3Martin Aspeli   Extending And Customising Plone 3
Martin Aspeli Extending And Customising Plone 3
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
 
Xdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP codeXdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP code
 
WebPagetest Power Users - Velocity 2014
WebPagetest Power Users - Velocity 2014WebPagetest Power Users - Velocity 2014
WebPagetest Power Users - Velocity 2014
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI
 
Simple webapps with nginx, uwsgi emperor and bottle
Simple webapps with nginx, uwsgi emperor and bottleSimple webapps with nginx, uwsgi emperor and bottle
Simple webapps with nginx, uwsgi emperor and bottle
 
AppengineJS
AppengineJSAppengineJS
AppengineJS
 
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
 
WebPagetest - Good, Bad & Ugly
WebPagetest - Good, Bad & UglyWebPagetest - Good, Bad & Ugly
WebPagetest - Good, Bad & Ugly
 
Odoo development workflow with pip and virtualenv
Odoo development workflow with pip and virtualenvOdoo development workflow with pip and virtualenv
Odoo development workflow with pip and virtualenv
 
Philipp Von Weitershausen Plone Age Mammoths, Sabers And Caveen Cant The...
Philipp Von Weitershausen   Plone Age  Mammoths, Sabers And Caveen   Cant The...Philipp Von Weitershausen   Plone Age  Mammoths, Sabers And Caveen   Cant The...
Philipp Von Weitershausen Plone Age Mammoths, Sabers And Caveen Cant The...
 
20151229 wnmp & phalcon micro app - part I
20151229 wnmp & phalcon micro app - part I20151229 wnmp & phalcon micro app - part I
20151229 wnmp & phalcon micro app - part I
 
SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)
 
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
 
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
 
Zenoss: Buildout
Zenoss: BuildoutZenoss: Buildout
Zenoss: Buildout
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 

Similar to Profiling PHP with Xdebug / Webgrind

Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101
Angus Li
 
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
Jim Jagielski
 
High Performance Web Sites
High Performance Web SitesHigh Performance Web Sites
High Performance Web Sites
Ravi Raj
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Steven Pignataro
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
Wim Godden
 
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP MeetupWeb Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Jonathan Klein
 
What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24
Jim Jagielski
 
Introduction to Magento Optimization
Introduction to Magento OptimizationIntroduction to Magento Optimization
Introduction to Magento Optimization
Fabio Daniele
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012
Wim Godden
 
Heavy Web Optimization: Backend
Heavy Web Optimization: BackendHeavy Web Optimization: Backend
Heavy Web Optimization: Backend
Võ Duy Tuấn
 
Lonestar php scalingmagento
Lonestar php scalingmagentoLonestar php scalingmagento
Lonestar php scalingmagento
Mathew Beane
 
Why we choose Symfony2
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2
Merixstudio
 
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability EnvironmentsSaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltStack
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
Marcelo Pinheiro
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
Greg Whalin
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
Justin Cataldo
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
Matteo Moretti
 
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
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on Steroids
SiteGround.com
 
Web Front End Performance
Web Front End PerformanceWeb Front End Performance
Web Front End Performance
Chris Love
 

Similar to Profiling PHP with Xdebug / Webgrind (20)

Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101
 
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
 
High Performance Web Sites
High Performance Web SitesHigh Performance Web Sites
High Performance Web Sites
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP MeetupWeb Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
 
What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24
 
Introduction to Magento Optimization
Introduction to Magento OptimizationIntroduction to Magento Optimization
Introduction to Magento Optimization
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012
 
Heavy Web Optimization: Backend
Heavy Web Optimization: BackendHeavy Web Optimization: Backend
Heavy Web Optimization: Backend
 
Lonestar php scalingmagento
Lonestar php scalingmagentoLonestar php scalingmagento
Lonestar php scalingmagento
 
Why we choose Symfony2
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2
 
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability EnvironmentsSaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on Steroids
 
Web Front End Performance
Web Front End PerformanceWeb Front End Performance
Web Front End Performance
 

Recently uploaded

The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
Larry Smarr
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
rajancomputerfbd
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
Stephanie Beckett
 
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Chris Swan
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
SynapseIndia
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
Tatiana Al-Chueyr
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
RaminGhanbari2
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
ishalveerrandhawa1
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
jackson110191
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
Eric D. Schabell
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc
 
Comparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdfComparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdf
Andrey Yasko
 
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly DetectionAdvanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Bert Blevins
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
BookNet Canada
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
Bert Blevins
 
20240702 QFM021 Machine Intelligence Reading List June 2024
20240702 QFM021 Machine Intelligence Reading List June 202420240702 QFM021 Machine Intelligence Reading List June 2024
20240702 QFM021 Machine Intelligence Reading List June 2024
Matthew Sinclair
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
Lidia A.
 
Cookies program to display the information though cookie creation
Cookies program to display the information though cookie creationCookies program to display the information though cookie creation
Cookies program to display the information though cookie creation
shanthidl1
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
Mark Billinghurst
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
BookNet Canada
 

Recently uploaded (20)

The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
 
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
 
Comparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdfComparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdf
 
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly DetectionAdvanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
 
20240702 QFM021 Machine Intelligence Reading List June 2024
20240702 QFM021 Machine Intelligence Reading List June 202420240702 QFM021 Machine Intelligence Reading List June 2024
20240702 QFM021 Machine Intelligence Reading List June 2024
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
 
Cookies program to display the information though cookie creation
Cookies program to display the information though cookie creationCookies program to display the information though cookie creation
Cookies program to display the information though cookie creation
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
 

Profiling PHP with Xdebug / Webgrind

  • 1. Profiling PHP Applications Sam Keen @samkeen pdxphp.org: May 2009 Meeting
  • 2. Summary • Huge topic, so we will settle on one aspect of it • Concentrate on the Code aspect of profiling • We’ll concern ourselves more with ‘tools to get started’ rather than ‘Preferment code best practices’ (see last slide for that) • Will introduce a ‘secret ingredient’ that makes profiling super delicious!
  • 3. The Scenario You build a killer PHP site Works great out of the gate but then slowly degrades as more people use it until...
  • 5. How do we avoid this Or at least lesson the chance of it happening or at a minimum reduce the amount of “material” hitting the fan when it inevitably occurs
  • 6. Profiling - should be done during development - allows you to spot inefficiencies and bottlenecks in code rather than your clients Photo: http://www.flickr.com/photos/chermida/2913511936/
  • 7. Facilitating Profiling During Development • Make it as easy as possible to set up and use • This way it can become part of your daily (OK, maybe weekly) routine.
  • 8. Many Aspects of Profiling Code Db System Network CPU/RAM
  • 9. First steps for Db and System/Network Query logs: slow and index-less top, vmstat, dstat $ dstat @see http://dag.wieers.com/home-made/dstat
  • 10. Profiling Code -Baseline- Before you make changes, you need to get some sort of baseline of the performance of the application Otherwise, you cannot measure improvement So start with profiling the site as a “whole”
  • 11. Web Server Profiling Tools Apache Bench HTTP_load Siege Web Server
  • 12. HTTP_Load Install wget http://www.acme.com/software/http_load/http_load-12mar2006.tar.gz tar -xzf http_load-12mar2006.tar.gz cd http_load-12mar2006/ make sudo make install @see eZ Publish article for coverage of the others: http://bit.ly/sKYha http://ez.no/developer/articles/ez_publish_performance_optimization_part_1_of_3_introduction_and_benchmarking
  • 13. HTTP_Load After creating for URL file (simple txt file with list o URLs (one per line) that will be randomly chosen from by http_load) The run something like: (runs for ten seconds, with five parallel requests) $ http_load -parallel 5 -seconds 10 urls.txt
  • 14. HTTP_Load Output $ http_load -parallel 5 -seconds 10 urls.txt 90 fetches, 5 max parallel, 805770 bytes, in 10 seconds 8953 mean bytes/connection 8.99999 fetches/sec, 80576.9 bytes/sec msecs/connect: 241.704 mean, 958.418 max, 73.01 min msecs/first-response: 252.075 mean, 1067.61 max, 83.833 min HTTP response codes: code 200 -- 90
  • 15. Xdebug Profiling Far more than just a profiler: * stack traces and function traces in error messages with: o full parameter display for user defined functions o function name, file name and line indications o support for member functions * memory allocation * protection for infinite recursions * profiling information for PHP scripts * code coverage analysis * debug your scripts interactively with a debug client @see xdebug.org
  • 16. Xdebug Install @see http://www.xdebug.org/docs/install Install with pecl sudo pecl install xdebug Add this line to your php.ini zend_extension=quot;/usr/local/php/modules/xdebug.soquot;
  • 17. Xdebug Configure ;##### START XDEBUG SECTION ######; zend_extension=/usr/lib/php/extensions/xdebug.so xdebug.remote_enable=on xdebug.remote_handle=dbgp xdebug.remote_host=localhost xdebug.remote_port=9000 xdebug.profiler_enable = 1 xdebug.profiler_output_name = cachegrind.out.%t-%s xdebug.profiler_output_dir=quot;/Users/sam/grind-outquot; ;##### END XDEBUG SECTION ######; http://www.xdebug.org/docs/all_settings#profiler_output_name
  • 18. Xdebug Local Setup php.ini@ -> /usr/local/php5/lib/php.ini.zenddebug php.ini.xdebug php.ini.xdebug.profile php.ini.zenddebug ~/bin (in my PATH) -rwxr-xr-x@ php-xdebug* -rwxr-xr-x@ php-xdebug-profile* -rwxr-xr-x@ php-zenddebug* Contents of php-xdebug-profile #!/bin/sh rm /usr/local/php5/lib/php.ini ln -s /usr/local/php5/lib/php.ini.xdebug.profile /usr/local/php5/lib/php.ini sudo apachectl restart $ php-xdebug-profile Now running php with Xdebug PROFILE: hurray for open source
  • 19. Profiling a specific page With Xdebug profiling enabled Simply request the web page in question using browser Look in your xdebug.profiler_output_dir for output cachegrind.out.1242152836-_Library_WebServer_Documents_persist_better_see_signups_php
  • 20. Examine the output • Traditionally: Kcachegrind • Install on Linux, or Windows: easy • Install on OSX: #&^!*&^!! • The Kcachegrind UI...
  • 22. And the Secret Ingredient
  • 23. Webgrind Webgrind is an Xdebug profiling web frontend in PHP5 @see http://code.google.com/p/webgrind/ Simple Installation on any platform that can run WebServer/PHP5 stack and the UI...
  • 25. Webgrind Install Install (Typical WebApp install: put the folder in your webroot and edit a config file) 1. Download to your web root * edit config.php * be sure $storageDir is writable by web server
  • 26. Extend UI UI is HTML and js (jquery) so trivial to make changes
  • 28. BaseLine $ http_load -parallel 5 -seconds 10 urls_could_improve.txt 1928 fetches, 5 max parallel, 1.92362e+07 bytes, in 10.0002 seconds 9977.27 mean bytes/connection 192.796 fetches/sec, 1.92358e+06 bytes/sec msecs/connect: 0.456549 mean, 9.326 max, 0.055 min msecs/first-response: 21.7894 mean, 599.711 max, 0.862 min HTTP response codes: code 200 -- 1928 *you would also be watching CPU and RAM with something like dstat during this test to determine if we are CPU and/or memory bound (see resources on last slide)
  • 29. Explore the output using WebGrind
  • 30. Lots of MDB2 at the top of the list
  • 31. Static Candidate (no code)
  • 32. Push Work to Client Push all this work to the client $('dd.note').each(function(i){ $(this).html($(this).text().replace(/(eb)/ig, '<span style=quot;color:red;font-weight:800;quot;>$1</span>') ); });
  • 33. Make Adjustments • Switch to PDO • typically lean towards php built-ins that abstract a great deal of functionality (rather than libs built in php). • Use static (.htm) pages if we don’t need DB • output buffer caching another alternative • Use js to ‘markup’ content • fastest way a web server can do work is not to do it changes took about 40 min of work
  • 34. Re-profile $ http_load -parallel 5 -seconds 10 urls_better.txt 5008 fetches, 5 max parallel, 3.40076e+07 bytes, in 10.0003 seconds 6790.65 mean bytes/connection 500.785 fetches/sec, 3.40066e+06 bytes/sec msecs/connect: 0.401153 mean, 9.334 max, 0.055 min msecs/first-response: 8.39298 mean, 259.332 max, 0.141 min HTTP response codes: code 200 -- 5008 Improvement fetches/sec: ~250% first-response: ~275%
  • 35. Resources Profiling articles form eZ Publish * http://ez.no/developer/articles/ez_publish_performance_optimization_part_1_of_3_introduction_and_benchmarking * http://ez.no/developer/articles/ ez_publish_performance_optimization_part_2_of_3_identifying_trouble_spots_by_debugging * http://ez.no/developer/articles/ ez_publish_performance_optimization_part_3_of_3_practical_cache_and_template_solutions Profiling articles form IBM * http://www.ibm.com/developerworks/linux/library/l-tune-lamp-1/ * http://www.ibm.com/developerworks/linux/library/l-tune-lamp-2.html * http://www.ibm.com/developerworks/library/l-tune-lamp-3.html Excellent Open Source PHP IDE which utilizes Xdebug (step through, profile, code coverage) * http://www.netbeans.org/features/php/index.html Profiling Presentation from core PHP folks * http://talks.php.net/index.php/Performance