Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Find WordPress performance bottlenecks with XDebug PHP profiling

752 views

Published on

Slides from the workshop given by Otto Kekäläinen at the Contributor Day at WordCamp Stockholm 2016

Published in: Software
  • Be the first to comment

  • Be the first to like this

Find WordPress performance bottlenecks with XDebug PHP profiling

  1. 1. @ottokekalainen @Seravocom SERAVO.COM Photo by Nicola Sapiens De Mitri Optimizing WordPress performance with XDebug and PHP profiling
  2. 2. @ottokekalainen @Seravocom SERAVO.COM XDebug a tool for developers to analyze PHP execution to find bottle necks and anomalies
  3. 3. @ottokekalainen @Seravocom SERAVO.COM Xdebug installation example: $ sudo apt-get install php-xdebug $ nano /etc/php/fpm/conf.d/20-xdebug.ini ; Enable xdebug zend_extension=xdebug.so ; Enable php profiling with get param XDEBUG_PROFILE=1 xdebug.profiler_output_dir=/tmp xdebug.profiler_output_name=cachegrind.out.%t.%p xdebug.profiler_enable_trigger=1 $ sudo service restart php-fpm Do this in your development environment, e.g. Vagrant image. Don't use production site, XDebug makes the site much slower!
  4. 4. @ottokekalainen @Seravocom SERAVO.COM Profiling run of WordPress front page /tmp $ curl -I http://example.com/?XDEBUG_PROFILE=1 /tmp $ ll -h 11M cachegrind.out.1455198789.5601 /tmp $ head cachegrind.out.1455198789.5601 version: 1 creator: xdebug 2.2.3 cmd: /data/wordpress/htdocs/index.php part: 1 positions: line events: Time fl=php:internal ...
  5. 5. @ottokekalainen @Seravocom SERAVO.COM Webgrind installation example: $ cd /data/wordpress/htdocs $ git clone https://github.com/alpha0010/webgrind $ sudo apt-get install graphviz
  6. 6. @ottokekalainen @Seravocom SERAVO.COM Go profiling!
  7. 7. @ottokekalainen @Seravocom SERAVO.COM
  8. 8. @ottokekalainen @Seravocom SERAVO.COM
  9. 9. @ottokekalainen @Seravocom SERAVO.COM Filter for usual suspects: load, open, curl, query
  10. 10. @ottokekalainen @Seravocom SERAVO.COM Pinpoint the bottle neck
  11. 11. @ottokekalainen @Seravocom SERAVO.COM Show call graph
  12. 12. @ottokekalainen @Seravocom SERAVO.COM Hunt down that rare beast: $ export LANG=C; for i in {1..99}; do curl -IL -H "Pragma: no-cache" -w "%{time_total}n" -o /dev/null -s "http://wp-esittely.wp-palvelu.fi/?XDEBUG_PROFILE=1"; done $ ll -Sh /tmp -rw-r--r-- 111M helmi 11 16:29 cachegrind.out.1455200976.5601 -rw-r--r-- 91M helmi 11 16:29 cachegrind.out.1455200984.5601 -rw-r--r-- 89M helmi 11 16:29 cachegrind.out.1455200972.5604 -rw-r--r-- 89M helmi 11 16:29 cachegrind.out.1455200964.5604 -rw-r--r-- 88M helmi 11 16:29 cachegrind.out.1455200973.5604 -rw-r--r-- 87M helmi 11 16:29 cachegrind.out.1455200963.5601 -rw-r--r-- 87M helmi 11 16:29 cachegrind.out.1455200967.5601
  13. 13. @ottokekalainen @Seravocom SERAVO.COM Rinse and repeat!
  14. 14. @ottokekalainen @Seravocom SERAVO.COM Now go and fix your slow code!
  15. 15. @ottokekalainen @Seravocom SERAVO.COM PROFESSIONAL UPKEEP FOR WORDPRESS Thank You!

×