High Performance
   WordPress
  WordCamp Jerusalem
   September 5, 2010
About Me

 Barry Abrahamson
 Systems Wrangler, Automattic
 http://barry.wordpress.com/contact-me/
WordPress.com
WordPress.com

 Launched in August 2005
WordPress.com

 Launched in August 2005
 ~13.5 million sites and 16 million users today
WordPress.com

 Launched in August 2005
 ~13.5 million sites and 16 million users today
 Over 2 billion HTTP requests per day
WordPress.com

 Launched in August 2005
 ~13.5 million sites and 16 million users today
 Over 2 billion HTTP requests per day
 Billions of MySQL queries per month
WordPress.com

 Launched in August 2005
 ~13.5 million sites and 16 million users today
 Over 2 billion HTTP requests per day
 Billions of MySQL queries per month
 500TB of bandwidth per week
What is Performance?
What is Performance?


  Speed - Serve each request as quickly as possible
What is Performance?


  Speed - Serve each request as quickly as possible
  Scaling - Serve many concurrent requests
Speed
Speed	
Server
Speed	
Server
  Generating the content
Speed	
Server
  Generating the content
Client
Speed	
Server
  Generating the content
Client
  Downloading
Speed	
Server
  Generating the content
Client
  Downloading
  Parsing
Speed	
Server
  Generating the content
Client
  Downloading
  Parsing
  Displaying
Speed	
Server
  Generating the content
Client
  Downloading
  Parsing
  Displaying
Client Side Performance
Client Side Performance
  80%+ of the total load time
Client Side Performance
  80%+ of the total load time
  Tools
Client Side Performance
  80%+ of the total load time
  Tools
    YSlow - http://developer.yahoo.com/yslow/
Client Side Performance
  80%+ of the total load time
  Tools
    YSlow - http://developer.yahoo.com/yslow/
    Page Speed - http://code.google.com/speed/
    page-speed/
Client Side Performance
Client Side Performance


Reduce number of HTTP Requests
Client Side Performance


Reduce number of HTTP Requests
Compress (gzip)
Client Side Performance


Reduce number of HTTP Requests
Compress (gzip)
Optimize images (resize, pngcrush, jpegtran)
Server Side Performance
Server Side Performance


More important than client side performance
Server Side Performance


More important than client side performance
Tools aren’t as advanced / fancy as client tools
Server Side Performance
Server Side Performance
Possible problems
Server Side Performance
Possible problems
  Slow database queries
Server Side Performance
Possible problems
  Slow database queries
  PHP (CPU)
Server Side Performance
Possible problems
  Slow database queries
  PHP (CPU)
  Network
Server Side Performance
Possible problems
  Slow database queries
  PHP (CPU)
  Network
Tools
Server Side Performance
Possible problems
  Slow database queries
  PHP (CPU)
  Network
Tools
  WordPress Plugins - Search for “debug”
WordPress.com Debug Tools
Server Side Performance
Server Side Performance	

Tools
Server Side Performance	

Tools
  MySQL Slow query log
Server Side Performance	

Tools
  MySQL Slow query log
  http://www.maatkit.org/doc/mk-query-digest.html
Server Side Performance	

Tools
  MySQL Slow query log
  http://www.maatkit.org/doc/mk-query-digest.html
  Strace / lsof / gdb
Server Side Performance	

Tools
  MySQL Slow query log
  http://www.maatkit.org/doc/mk-query-digest.html
  Strace / lsof / gdb
Many times plugins are the culprit.
How can I improve
  performance?
As a User
As a User

Make sure you are running the latest WordPress!
As a User

Make sure you are running the latest WordPress!
  Constant performance improvements being made.
  Many from things found on WordPress.com
As a User

Make sure you are running the latest WordPress!
  Constant performance improvements being made.
  Many from things found on WordPress.com
Show a reasonable number of posts per page. 10-25
seems to be good
As a User

Make sure you are running the latest WordPress!
  Constant performance improvements being made.
  Many from things found on WordPress.com
Show a reasonable number of posts per page. 10-25
seems to be good
Monitor site performance
As a Sysadmin
As a Sysadmin

Opcode cache (APC)
As a Sysadmin

Opcode cache (APC)
Caching plugins (Batcache, WP super cache)
As a Sysadmin

Opcode cache (APC)
Caching plugins (Batcache, WP super cache)
Make sure you are running the latest PHP
As a Sysadmin

Opcode cache (APC)
Caching plugins (Batcache, WP super cache)
Make sure you are running the latest PHP
HipHop
As a Sysadmin

Opcode cache (APC)
Caching plugins (Batcache, WP super cache)
Make sure you are running the latest PHP
HipHop
Apache + mod_php < Nginx + php-fpm.
Real World Numbers
Real World Numbers	

APC
Real World Numbers	

APC
 Empty cache - 33.5 MB RAM
Real World Numbers	

APC
 Empty cache - 33.5 MB RAM
 Primed cache - 6.2 MB RAM
Real World Numbers	

APC
 Empty cache - 33.5 MB RAM
 Primed cache - 6.2 MB RAM
 60% reduction in CPU utilization ( 2160 CPUs )
Real World Numbers	

APC
  Empty cache - 33.5 MB RAM
  Primed cache - 6.2 MB RAM
  60% reduction in CPU utilization ( 2160 CPUs )
PHP 5.3.3 10% CPU reduction ( 360 CPUs )
Real World Numbers
Real World Numbers

HipHop
Real World Numbers

HipHop
 40% faster ( http://huichen.org/en/2010/06/
 wordpress-3-benchmark/ )
Real World Numbers

HipHop
 40% faster ( http://huichen.org/en/2010/06/
 wordpress-3-benchmark/ )
 270% faster ( http://huichen.org/en/2010/06/
 wordpress-3-benchmark-part-2/ )
Real World Numbers
Apache + mod_php

1 request requiring php


  Using mod_php, php is
  loaded for every request
  even if not needed
  Most scaling problems are
  because of this
As a Developer
As a Developer


Only perform write operations when needed. Example
is flushing rewrite rules on every page load
As a Developer


Only perform write operations when needed. Example
is flushing rewrite rules on every page load
Use WordPress functions when possible.
WordPress.com
WordPress.com

 ~ 1100 servers in 3 datacenters
 ~ 450 web servers (8 CPU cores)
 ~ 400 database servers (lots of SSDs)
 ~ 75 memcached servers (800GB of RAM)
Scaling Tips
Scaling Tips

  Most things you do to scale WordPress apply to
  any web app
Scaling Tips

  Most things you do to scale WordPress apply to
  any web app
  If your bottleneck is the database, something is
  wrong
Scaling Tips

  Most things you do to scale WordPress apply to
  any web app
  If your bottleneck is the database, something is
  wrong
  Measure twice, cut once, measure again
Scaling Tips

  Most things you do to scale WordPress apply to
  any web app
  If your bottleneck is the database, something is
  wrong
  Measure twice, cut once, measure again
  Don’t optimize if you don’t need to
Questions?

High Performance WordPress - WordCamp Jerusalem 2010

Editor's Notes

  • #9 Serving lots of viruses quickly is not the kind of performance we want!
  • #10 Serving lots of viruses quickly is not the kind of performance we want!
  • #60 Talk about most common scaling problem. Database connection errors.