SlideShare a Scribd company logo
Use Xdebug to profile PHP
Premium hosting
and upkeep for
WordPress
HTTP/2
TESTED
UPDATES
24/7 UPKEEP
Top-notch performance
A comparison published by a
Google employee at
ismyhostfastyet.com
confirms that Seravo’s
customer sites load faster
than competing services’.
The study used
time-to-first-byte (TTFB)
measurement data from real
users as collected from the
Chrome browser UX data. Fast/Average/Slow TTFB by WordPress Host
Seravo recommends Xdebug
● Xdebug is open source: github.com/xdebug/xdebug
● Embraced by the PHP community
● Plenty of features: profiling, stack traces, debugging..
● Included in Linux distributions, easy to install
● Pre-installed in many development environments
○ Varying Vagrant Vagrants (for WordPress core contributors)
■ xdebug_on
○ Seravo WordPress Vagrant and Docker images (for Seravo’s customers)
■ wp-xdebug-on
What on earth is PHP doing?!
Finding the code bottlenecks is
hard without proper tools.
Solution:
● Profile PHP code with
Xdebug
● Browse results with
Webgrind
● Visualize code path with
Gprof2dot and Dot
All WordPress site
developers should learn
Xdebug
It is
easy!
Very easy with Seravo WordPress dev
● Enable by running: wp-xdebug-on
● Run profiler on any URL easily by appending one
parameter
○ E.g. https://wordpress.local/?XDEBUG_PROFILE
● Files are generated at /tmp/cachegrind.out.x.y.z
● Browse results with Webgrind
○ E.g. http://wordpress.local/.seravo/webgrind/
Documentation at seravo.com/docs/development/xdebug/
DEMO
Typical issues: database
Typically developers don’t test
their plugins with large amounts
of data and they work well on
small sites.
As sites grow, all problems related
to excess data manipulation
become visible.
Solution:
● Inject more data on a test site
and see how it behaves.
● In code, don’t fetch
everything from the database.
Remember LIMIT in SQL and
posts_per_page in WP_Query.
● Design code to fetch only
what is needed for the view,
nothing else.
Switch to
Polylang
for faster
page loads
Typical issues: HTTP requests
External API calls in PHP
typically also block the entire
site from loading if the
external API is down.
Solution:
● Review use of wp_remote_get(),
fopen() and similar
● Store result and avoid re-fetching it all
the time using WP Transients API
Use WP Transients API
Store the result of a heavy/slow computation to avoid having to do it all
the time (e.g. HTTP requests or heavy database queries):
More at: seravo.com/blog/faster-wordpress-with-transients/
and developer.wordpress.org/apis/handbook/transients/
Extra helper: wp-speed-test
vagrant@development:~$ wp-speed-test
Testing speed URL https://wordpress.local...
For an explanation of the different times, please see docs at https://curl.haxx.se/docs/manpage.html
URL TOTAL NAMELOOKUP CONNECT APPCONNECT PRETRANSFER STARTTRANSFER = AVG
https://wordpress.local 0.179 0.004 0.004 0.014 0.014 0.179 0.179
https://wordpress.local 0.154 0.000 0.000 0.000 0.000 0.154 0.167
https://wordpress.local 0.157 0.000 0.000 0.000 0.000 0.157 0.164
https://wordpress.local 0.167 0.000 0.000 0.000 0.000 0.167 0.164
https://wordpress.local 0.163 0.000 0.000 0.000 0.000 0.162 0.169
https://wordpress.local 0.147 0.000 0.000 0.000 0.000 0.147 0.168
https://wordpress.local 0.169 0.000 0.000 0.000 0.000 0.169 0.168
https://wordpress.local 0.178 0.000 0.000 0.000 0.000 0.178 0.168
https://wordpress.local 0.167 0.000 0.000 0.000 0.000 0.167 0.168
Test completed. If the values seems too high, please profile your PHP code to find potential
bottlenecks. Note that this test tells how fast your site is in the sense of how long it takes for PHP
to generate the HTML output. To test how much load the site can handle, run wp-load-test.
Hunt for random slowness
$ wp-speed-test https://wordpress.local/hello-world/?XDEBUG_PROFILE
Testing speed URL https://wordpress.local/hello-world/?XDEBUG_PROFILE...
For an explanation of the different times, please see docs at https://curl.haxx.se/docs/manpage.html
URL TOTAL NAMELOOKUP CONNECT APPCONNECT PRETRANSFER STARTTRANSFER = AVG
https://wordpress.local/hel... 0.637 0.004 0.004 0.013 0.013 0.636 0.637
https://wordpress.local/hel... 0.469 0.000 0.000 0.000 0.000 0.468 0.553
https://wordpress.local/hel... 0.512 0.000 0.000 0.000 0.000 0.511 0.539
https://wordpress.local/hel... 0.484 0.000 0.000 0.000 0.000 0.483 0.525
https://wordpress.local/hel... 0.483 0.000 0.000 0.000 0.000 0.482 0.517
https://wordpress.local/hel... 0.556 0.000 0.000 0.000 0.000 0.555 0.524
https://wordpress.local/hel... 0.910 0.000 0.000 0.000 0.000 0.908 0.640
https://wordpress.local/hel... 0.496 0.000 0.000 0.000 0.000 0.495 0.633
https://wordpress.local/hel... 0.475 0.000 0.000 0.000 0.000 0.474 0.625
16 MB
Always remember to measure
before and after!
seravo.com/docs
Instructions for
WordPress site
developers
Lots of tips out there!
The database is often the
performance bottleneck. See my
other talk on WordPress and
database optimization:
More in-depth code profiling tips
in my WordPress performance
talk:
wordpress.tv/?s=otto+kekäläinen
See also
Make Your Site Faster with Caching
https://seravo.com/blog/wordpress-cache/
300% faster WordPress load times with transients
https://seravo.com/blog/faster-wordpress-with-transients/
5 common reasons why your WordPress site is slow
https://youtu.be/8sJExUO-U4A
Improving WordPress Performance with XDebug and PHP Profiling
https://youtu.be/oKcIS5A-6_c
Thank you!
Seravo.com @Seravo @ottokekalainen

More Related Content

PDF
Less and faster – Cache tips for WordPress developers
PDF
Search in WordPress - how it works and howto customize it
PDF
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
PDF
Seravo.com: WordPress Security 101
PDF
How to investigate and recover from a security breach in WordPress
PDF
10 things every developer should know about their database to run word press ...
PDF
Improving WordPress Performance with Xdebug and PHP Profiling
PDF
Improving WordPress performance (xdebug and profiling)
Less and faster – Cache tips for WordPress developers
Search in WordPress - how it works and howto customize it
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
Seravo.com: WordPress Security 101
How to investigate and recover from a security breach in WordPress
10 things every developer should know about their database to run word press ...
Improving WordPress Performance with Xdebug and PHP Profiling
Improving WordPress performance (xdebug and profiling)

What's hot (20)

PDF
Automatic testing and quality assurance for WordPress plugins
PPTX
Anthony Somerset - Site Speed = Success!
PDF
Find WordPress performance bottlenecks with XDebug PHP profiling
PDF
Scalable talk notes
PDF
Scaling WordPress
PDF
Automatic testing and quality assurance for WordPress plugins and themes
PDF
Care and feeding notes
PDF
04 web optimization
ODP
Choosing a Web Architecture for Perl
PDF
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
PDF
WPDay Bologna 2013
PPTX
Front end performance optimization
PDF
High Performance WordPress
PDF
Pagespeed what, why, and how it works
PPTX
WordPress performance tuning
PDF
Front End Performance
PDF
WordCamp Finland 2015 - WordPress Security
PPT
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”
PDF
DrupalCon Barcelona 2015
PDF
Improve WordPress performance with caching and deferred execution of code
Automatic testing and quality assurance for WordPress plugins
Anthony Somerset - Site Speed = Success!
Find WordPress performance bottlenecks with XDebug PHP profiling
Scalable talk notes
Scaling WordPress
Automatic testing and quality assurance for WordPress plugins and themes
Care and feeding notes
04 web optimization
Choosing a Web Architecture for Perl
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
WPDay Bologna 2013
Front end performance optimization
High Performance WordPress
Pagespeed what, why, and how it works
WordPress performance tuning
Front End Performance
WordCamp Finland 2015 - WordPress Security
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”
DrupalCon Barcelona 2015
Improve WordPress performance with caching and deferred execution of code
Ad

Similar to Use Xdebug to profile PHP (20)

PPTX
Scraping the web with Laravel, Dusk, Docker, and PHP
PDF
Optimizing WordPress PHP performance with Tideways
PPT
Building dynamic websites with Mod perl and apache
PDF
Profiling PHP with Xdebug / Webgrind
PDF
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
PPTX
Google App Engine for PHP
PDF
Using the new WordPress REST API
PDF
Automated Tasks for WordPress
PPTX
Improving WordPress Performance: Xdebug and PHP profiling
PPTX
Caching 101
PDF
PDF
2013 - Dustin whittle - Escalando PHP en la vida real
PDF
Mastering WordPress Vol.1
ODP
PHP BASIC PRESENTATION
PDF
Scaling PHP apps
PPT
T2 Web Framework
PDF
ApacheConNA 2015: What's new in Apache httpd 2.4
PDF
Madison PHP 2015 - DevOps For Small Teams
ODP
Using PHP with IBM Bluemix
PDF
ZendCon 2015 - DevOps for Small Teams
Scraping the web with Laravel, Dusk, Docker, and PHP
Optimizing WordPress PHP performance with Tideways
Building dynamic websites with Mod perl and apache
Profiling PHP with Xdebug / Webgrind
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
Google App Engine for PHP
Using the new WordPress REST API
Automated Tasks for WordPress
Improving WordPress Performance: Xdebug and PHP profiling
Caching 101
2013 - Dustin whittle - Escalando PHP en la vida real
Mastering WordPress Vol.1
PHP BASIC PRESENTATION
Scaling PHP apps
T2 Web Framework
ApacheConNA 2015: What's new in Apache httpd 2.4
Madison PHP 2015 - DevOps For Small Teams
Using PHP with IBM Bluemix
ZendCon 2015 - DevOps for Small Teams
Ad

Recently uploaded (20)

PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Nekopoi APK 2025 free lastest update
PDF
System and Network Administration Chapter 2
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Transform Your Business with a Software ERP System
PPTX
history of c programming in notes for students .pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
AI in Product Development-omnex systems
PPTX
L1 - Introduction to python Backend.pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
How to Choose the Right IT Partner for Your Business in Malaysia
CHAPTER 2 - PM Management and IT Context
Nekopoi APK 2025 free lastest update
System and Network Administration Chapter 2
Wondershare Filmora 15 Crack With Activation Key [2025
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Navsoft: AI-Powered Business Solutions & Custom Software Development
Transform Your Business with a Software ERP System
history of c programming in notes for students .pptx
Design an Analysis of Algorithms II-SECS-1021-03
ManageIQ - Sprint 268 Review - Slide Deck
Which alternative to Crystal Reports is best for small or large businesses.pdf
Understanding Forklifts - TECH EHS Solution
AI in Product Development-omnex systems
L1 - Introduction to python Backend.pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Design an Analysis of Algorithms I-SECS-1021-03
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx

Use Xdebug to profile PHP

  • 1. Use Xdebug to profile PHP
  • 2. Premium hosting and upkeep for WordPress HTTP/2 TESTED UPDATES 24/7 UPKEEP
  • 3. Top-notch performance A comparison published by a Google employee at ismyhostfastyet.com confirms that Seravo’s customer sites load faster than competing services’. The study used time-to-first-byte (TTFB) measurement data from real users as collected from the Chrome browser UX data. Fast/Average/Slow TTFB by WordPress Host
  • 4. Seravo recommends Xdebug ● Xdebug is open source: github.com/xdebug/xdebug ● Embraced by the PHP community ● Plenty of features: profiling, stack traces, debugging.. ● Included in Linux distributions, easy to install ● Pre-installed in many development environments ○ Varying Vagrant Vagrants (for WordPress core contributors) ■ xdebug_on ○ Seravo WordPress Vagrant and Docker images (for Seravo’s customers) ■ wp-xdebug-on
  • 5. What on earth is PHP doing?! Finding the code bottlenecks is hard without proper tools. Solution: ● Profile PHP code with Xdebug ● Browse results with Webgrind ● Visualize code path with Gprof2dot and Dot
  • 6. All WordPress site developers should learn Xdebug It is easy!
  • 7. Very easy with Seravo WordPress dev ● Enable by running: wp-xdebug-on ● Run profiler on any URL easily by appending one parameter ○ E.g. https://wordpress.local/?XDEBUG_PROFILE ● Files are generated at /tmp/cachegrind.out.x.y.z ● Browse results with Webgrind ○ E.g. http://wordpress.local/.seravo/webgrind/ Documentation at seravo.com/docs/development/xdebug/
  • 9. Typical issues: database Typically developers don’t test their plugins with large amounts of data and they work well on small sites. As sites grow, all problems related to excess data manipulation become visible. Solution: ● Inject more data on a test site and see how it behaves. ● In code, don’t fetch everything from the database. Remember LIMIT in SQL and posts_per_page in WP_Query. ● Design code to fetch only what is needed for the view, nothing else.
  • 11. Typical issues: HTTP requests External API calls in PHP typically also block the entire site from loading if the external API is down. Solution: ● Review use of wp_remote_get(), fopen() and similar ● Store result and avoid re-fetching it all the time using WP Transients API
  • 12. Use WP Transients API Store the result of a heavy/slow computation to avoid having to do it all the time (e.g. HTTP requests or heavy database queries): More at: seravo.com/blog/faster-wordpress-with-transients/ and developer.wordpress.org/apis/handbook/transients/
  • 13. Extra helper: wp-speed-test vagrant@development:~$ wp-speed-test Testing speed URL https://wordpress.local... For an explanation of the different times, please see docs at https://curl.haxx.se/docs/manpage.html URL TOTAL NAMELOOKUP CONNECT APPCONNECT PRETRANSFER STARTTRANSFER = AVG https://wordpress.local 0.179 0.004 0.004 0.014 0.014 0.179 0.179 https://wordpress.local 0.154 0.000 0.000 0.000 0.000 0.154 0.167 https://wordpress.local 0.157 0.000 0.000 0.000 0.000 0.157 0.164 https://wordpress.local 0.167 0.000 0.000 0.000 0.000 0.167 0.164 https://wordpress.local 0.163 0.000 0.000 0.000 0.000 0.162 0.169 https://wordpress.local 0.147 0.000 0.000 0.000 0.000 0.147 0.168 https://wordpress.local 0.169 0.000 0.000 0.000 0.000 0.169 0.168 https://wordpress.local 0.178 0.000 0.000 0.000 0.000 0.178 0.168 https://wordpress.local 0.167 0.000 0.000 0.000 0.000 0.167 0.168 Test completed. If the values seems too high, please profile your PHP code to find potential bottlenecks. Note that this test tells how fast your site is in the sense of how long it takes for PHP to generate the HTML output. To test how much load the site can handle, run wp-load-test.
  • 14. Hunt for random slowness $ wp-speed-test https://wordpress.local/hello-world/?XDEBUG_PROFILE Testing speed URL https://wordpress.local/hello-world/?XDEBUG_PROFILE... For an explanation of the different times, please see docs at https://curl.haxx.se/docs/manpage.html URL TOTAL NAMELOOKUP CONNECT APPCONNECT PRETRANSFER STARTTRANSFER = AVG https://wordpress.local/hel... 0.637 0.004 0.004 0.013 0.013 0.636 0.637 https://wordpress.local/hel... 0.469 0.000 0.000 0.000 0.000 0.468 0.553 https://wordpress.local/hel... 0.512 0.000 0.000 0.000 0.000 0.511 0.539 https://wordpress.local/hel... 0.484 0.000 0.000 0.000 0.000 0.483 0.525 https://wordpress.local/hel... 0.483 0.000 0.000 0.000 0.000 0.482 0.517 https://wordpress.local/hel... 0.556 0.000 0.000 0.000 0.000 0.555 0.524 https://wordpress.local/hel... 0.910 0.000 0.000 0.000 0.000 0.908 0.640 https://wordpress.local/hel... 0.496 0.000 0.000 0.000 0.000 0.495 0.633 https://wordpress.local/hel... 0.475 0.000 0.000 0.000 0.000 0.474 0.625 16 MB
  • 15. Always remember to measure before and after!
  • 17. Lots of tips out there! The database is often the performance bottleneck. See my other talk on WordPress and database optimization: More in-depth code profiling tips in my WordPress performance talk: wordpress.tv/?s=otto+kekäläinen
  • 18. See also Make Your Site Faster with Caching https://seravo.com/blog/wordpress-cache/ 300% faster WordPress load times with transients https://seravo.com/blog/faster-wordpress-with-transients/ 5 common reasons why your WordPress site is slow https://youtu.be/8sJExUO-U4A Improving WordPress Performance with XDebug and PHP Profiling https://youtu.be/oKcIS5A-6_c
  • 19. Thank you! Seravo.com @Seravo @ottokekalainen