Smaller, faster PHP

An introduction to backend performance optimization

Jonathan Brinley

Modern Tribe

Flightless

Google announces it will be using site speed as a factor in web search ranking
http://googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html
http://www.strangeloopnetworks.com/
Visualizing web performance

“Only 10–20% of the end user response time is spent downloading the HTML document. The other 80–90% is spent downloading all the components in the page.”

Steve Souders, High Performance Web Sites: Essential Knowledge for Front-End Engineers
Time to First Byte
Chrome dev tools showing the load time for google.com
Time to First Byte
Chrome dev tools showing the load time for readme.html
Time to First Byte
Chrome dev tools showing the load time for a WordPress home page
Time to First Byte
Chrome dev tools showing the load time for a slow WordPress home page
Banner for the FakerPress WordPress plugin
https://wordpress.org/plugins/fakerpress/
Why is this so slow?
Chrome dev tools showing the load time for a slow WordPress home page

Debug Bar

Banner for the Debug Bar WordPress plugin
https://wordpress.org/plugins/debug-bar/
https://wordpress.org/plugins/debug-bar-extender/
https://wordpress.org/plugins/debug-bar-remote-requests/
Profiler
Debug bar profiler tab, showing total execution time of 7,970.24ms
MySQL Queries
Debug bar queries tab, showing 154 queries in 679.2ms

define( 'WP_DEBUG', true );
define( 'SAVEQUERIES', true );
				
Remote Requests
Debug bar remote requests tab, showing 1 request taking 1.452s
object-cache.php
Debug bar queries tab, showing 48 queries in 600.0ms
https://goo.gl/gwaqwp
Remote Requests
Debug bar remote requests tab, showing 1 request taking 1.452s

Cache!

Remote Requests
Debug bar remote requests tab, showing 0 requests taking 0.0ms
MySQL Queries
Debug bar queries tab, showing 48 queries in 600.0ms
Debug bar queries tab, showing a query that takes 172.1ms
EXPLAIN
Result of a MySQL EXPLAIN query
https://dev.mysql.com/doc/refman/5.0/en/explain-output.html
Debug bar queries tab, showing a query that takes 55.3ms

Cache!

TLC Transients

https://github.com/markjaquith/WP-TLC-Transients

MySQL Queries
Debug bar queries tab, showing 47 queries in 439.6ms
Debug bar queries tab, showing a query that takes 19.1ms

Cache!

MySQL Queries
Debug bar queries tab, showing 26 queries in 300.3ms
Debug bar queries tab, showing a query that takes 9.3ms
MySQL Queries
Debug bar queries tab, showing 13 queries in 161.0ms
Profiler
Debug bar profiler tab, showing total execution time of 4,866.03ms
Debug bar profiler tab, showing a the_post actions that takes around 500ms each
Xdebug Profiler
An analyzed xDebug profiler shapshot in PhpStorm
http://xdebug.org/
Profiler
Debug bar profiler tab, showing total execution time of 1,248.48ms
Xdebug Profiler
An analyzed xDebug profiler shapshot in PhpStorm
MySQL Queries
Debug bar queries tab, showing 13 queries in 256.1ms
Debug bar queries tab, showing a query that takes 23.8ms

Cache!

MySQL Queries
Debug bar queries tab, showing 3 queries in 6.3ms
Profiler
Debug bar profiler tab, showing total execution time of 917.44ms
Chrome dev tools showing the load time for our optimized WordPress home page

$start = microtime( true );
// something you want to profile goes here
echo '';
// you could also send this to error_log()
			
New Relic logo
http://newrelic.com/
New Relic response time graph
New Relic transactions list
New Relic MySQL graph

Questions?

Jonathan Brinley

http://xplus3.net/ • jonathan@tri.be • @jbrinley

Modern Tribe

Flightless