WordPress
Performance & Scalability

            Joseph Scott
       http://josephscott.org/
Find Me

• http://josephscott.org/
• joseph@josephscott.org
• http://twitter.com/josephscott/
• #wordpress-dev
Backup First
Performance




Shelby Supercars Ultimate Aero Twin Turbo
Scalability
Web Apps Are Like
 Ogres Onions
Start At The Bottom
       Deal with network
       problems / bottlenecks
       first

       Be familiar with Operating
...
Web Server


  Apache?
Web Server
nginx                           LiteSpeed
http://nginx.net/               http://litespeedtech.com/




     li...
Apache
• Can be a pig, remove any modules you aren’t
  using
• Turn off host name lookups
• Turn on compression (mod_deflat...
PHP
• Use an opcode cache (APC, lots of others)
• Don’t use on static files (unless you really,
  really need to)
• Conside...
MySQL - Table Types
MyISAM
• High performance reads or writes, not
  both
• Full text search
InnoDB
• Better for mixed rea...
MySQL
• Double (and triple) check indexes
• Tune your configuration
  • key_buffer_size, table_cache,
    sort_buffer_size,...
Memcache

In memory object cache, learn it, use it, love it


                 With Caution
WordPress
• MySQL tables default to using MyISAM,
  consider using InnoDB instead
• Turn off unused plugins
• Check that t...
Construction

     Start from the bottom and
     work your way up
Test Setup
• Ubuntu 9.04 server edition
• Apache 2.2.11
• PHP 5.2.6
• MySQL 5.0.75
• WordPress -trunk
Test “Hardware”

Parallels 4.0
     2.66 Xeon
     1 GB Ram
Abusing The Server
siege - http://www.joedog.org/index/siege-home

   siege -d 1 -c 50 -r 10 http://192.168.1.100/
Below The Baseline

Zero Byte HTML - zero.html
              (80 r/s) ~0.01 s/r

  Zero Byte PHP - zero.php
              ...
a phpinfo( )’s worth
                        51,213 / 8,689 bytes




static HTML - phpinfo.html
         100% (75 r/s) ~0...
Hello World!
              6,582 / 2,531 bytes




WordPress: /wp/?p=1
Hello World!
                 6,582 / 2,531 bytes




WordPress: /wp/?p=1
        8% (6 r/s) ~7 s/r
Hello World!
   + APC
WordPress: /wp/?p=1
    29% (22 r/s) ~1.51 s/r
Use An Opcode Cache!
  %8 ~7     %29 ~1.51
Use An Opcode Cache!
  %8 ~7     %29 ~1.51
WordPress + Memcache

• Ryan Boren
• Stores WordPress data in Memcache
• Reduces the number of database queries
• http://r...
Hello World!
+ APC + Memcache
 WordPress: /wp/?p=1
      32% (24 r/s) ~1.4 s/r
Batcache!
WordPress + Batcache

• Andy Skelton
• Stores rendered HTML in Memcache
• http://wordpress.org/extend/plugins/batcache/
Hello World! + APC +
Memcache + Batcache
 WordPress: /wp/?p=1
      80% (60 r/s) ~0.4 s/r
Hello World! + APC +
Memcache + Batcache
WordPress
     + WP Super Cache
• Donncha O Caoimh
• Stores rendered HTML on disk
• http://wordpress.org/extend/plugins/wp...
Let me 'splain. ...
No, there is too much. Let me sum up.
                     Requests Seconds per
   Description        ...
What Now?
All In One



 Web / Database
Moving Out


Web         Database
Paying In Cache

           Web

Memcache         Database
But Wait, There’s More!
MySQL Replication
• Master / Slave - one way asynchronous
• Send writes to the master, reads to the
  slave(s)
• Replicati...
Enter HyperDB
• Drop in replacement for the default
  WordPress database class
• Supports distributed reads/writes
• Parti...
Replicated Data

                    DB Master
           Web

Memcache
                    DB Slave
A Balancing Act
                Load Balancer




Web 1   Web 2        Web 3
Variations on a Theme

• Master / Relay / Slave
• Slave just for backups
• Multiple data centers
• Task specific web servers
When Everything Goes
      Wrong
Hire An Amazing
   SysAdmin
Thank You
Find Me

• http://josephscott.org/
• joseph@josephscott.org
• http://twitter.com/josephscott/
• #wordpress-dev
Upcoming SlideShare
Loading in...5
×

WordPress Performance & Scalability

5,572

Published on

Published in: Technology, Business
1 Comment
5 Likes
Statistics
Notes
  • We'd love your feedback on our new wordpress monitoring and management tool - see inside your app and see what's slow, 2 minutes after installing our agent. If you have Wordpress performance problems, you should try out New Relic -- http://www.newrelic.com - we just released an agent that let's you see inside your wordpress/php app and see what's slow. We'd love your feedback. Check out how we do it: http://blog.newrelic.com/2010/12/16/measuring-wordpress-performance-with-new-relic-rpm/

    It is super easy to setup. Let me know if you think this might be valuable!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
5,572
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
68
Comments
1
Likes
5
Embeds 0
No embeds

No notes for slide

WordPress Performance & Scalability

  1. 1. WordPress Performance & Scalability Joseph Scott http://josephscott.org/
  2. 2. Find Me • http://josephscott.org/ • joseph@josephscott.org • http://twitter.com/josephscott/ • #wordpress-dev
  3. 3. Backup First
  4. 4. Performance Shelby Supercars Ultimate Aero Twin Turbo
  5. 5. Scalability
  6. 6. Web Apps Are Like Ogres Onions
  7. 7. Start At The Bottom Deal with network problems / bottlenecks first Be familiar with Operating System network optimizations
  8. 8. Web Server Apache?
  9. 9. Web Server nginx LiteSpeed http://nginx.net/ http://litespeedtech.com/ lighttpd Zeus http://www.lighttpd.net/ http://www.zeus.com/
  10. 10. Apache • Can be a pig, remove any modules you aren’t using • Turn off host name lookups • Turn on compression (mod_deflate) • Turn off FollowSymLinks (and .htaccess if you can) • Skip Apache all together, serve static content from another server
  11. 11. PHP • Use an opcode cache (APC, lots of others) • Don’t use on static files (unless you really, really need to) • Consider output buffering • Be careful with preg_* functions
  12. 12. MySQL - Table Types MyISAM • High performance reads or writes, not both • Full text search InnoDB • Better for mixed reads/writes • Transactions, Foreign Keys
  13. 13. MySQL • Double (and triple) check indexes • Tune your configuration • key_buffer_size, table_cache, sort_buffer_size, read_buffer_size • Replication (more on that later) • Interesting quirks, get familiar with them
  14. 14. Memcache In memory object cache, learn it, use it, love it With Caution
  15. 15. WordPress • MySQL tables default to using MyISAM, consider using InnoDB instead • Turn off unused plugins • Check that themes and plugins aren’t abusing MySQL or PHP • Server static content from another server (optimized for that task)
  16. 16. Construction Start from the bottom and work your way up
  17. 17. Test Setup • Ubuntu 9.04 server edition • Apache 2.2.11 • PHP 5.2.6 • MySQL 5.0.75 • WordPress -trunk
  18. 18. Test “Hardware” Parallels 4.0 2.66 Xeon 1 GB Ram
  19. 19. Abusing The Server siege - http://www.joedog.org/index/siege-home siege -d 1 -c 50 -r 10 http://192.168.1.100/
  20. 20. Below The Baseline Zero Byte HTML - zero.html (80 r/s) ~0.01 s/r Zero Byte PHP - zero.php (80 r/s) ~0.01 s/r
  21. 21. a phpinfo( )’s worth 51,213 / 8,689 bytes static HTML - phpinfo.html 100% (75 r/s) ~0.04 s/r PHP - phpinfo.php 92% (69 r/s) ~0.04 s/r
  22. 22. Hello World! 6,582 / 2,531 bytes WordPress: /wp/?p=1
  23. 23. Hello World! 6,582 / 2,531 bytes WordPress: /wp/?p=1 8% (6 r/s) ~7 s/r
  24. 24. Hello World! + APC WordPress: /wp/?p=1 29% (22 r/s) ~1.51 s/r
  25. 25. Use An Opcode Cache! %8 ~7 %29 ~1.51
  26. 26. Use An Opcode Cache! %8 ~7 %29 ~1.51
  27. 27. WordPress + Memcache • Ryan Boren • Stores WordPress data in Memcache • Reduces the number of database queries • http://ryan.wordpress.com/2005/12/23/ memcached-backend/
  28. 28. Hello World! + APC + Memcache WordPress: /wp/?p=1 32% (24 r/s) ~1.4 s/r
  29. 29. Batcache!
  30. 30. WordPress + Batcache • Andy Skelton • Stores rendered HTML in Memcache • http://wordpress.org/extend/plugins/batcache/
  31. 31. Hello World! + APC + Memcache + Batcache WordPress: /wp/?p=1 80% (60 r/s) ~0.4 s/r
  32. 32. Hello World! + APC + Memcache + Batcache
  33. 33. WordPress + WP Super Cache • Donncha O Caoimh • Stores rendered HTML on disk • http://wordpress.org/extend/plugins/wp-super- cache/
  34. 34. Let me 'splain. ... No, there is too much. Let me sum up. Requests Seconds per Description Potential per Second request (mean) Zero Bytes 80 ~0.01 - Static phpinfo() 75 ~0.04 100% phpinfo() 69 ~0.04 92% OOB WP 6 ~7.00 8% WP & APC 22 ~1.51 29% WP & APC/ 24 ~1.40 32% Memcache WP & APC/ 60 ~0.04 80% Memcache/Batcache
  35. 35. What Now?
  36. 36. All In One Web / Database
  37. 37. Moving Out Web Database
  38. 38. Paying In Cache Web Memcache Database
  39. 39. But Wait, There’s More!
  40. 40. MySQL Replication • Master / Slave - one way asynchronous • Send writes to the master, reads to the slave(s) • Replication works on both MyISAM and InnoDB tables • Supports multiple slaves and replication chaining
  41. 41. Enter HyperDB • Drop in replacement for the default WordPress database class • Supports distributed reads/writes • Partition data (helpful for large WPMU installs) • Failover support when a database goes down • http://codex.wordpress.org/HyperDB
  42. 42. Replicated Data DB Master Web Memcache DB Slave
  43. 43. A Balancing Act Load Balancer Web 1 Web 2 Web 3
  44. 44. Variations on a Theme • Master / Relay / Slave • Slave just for backups • Multiple data centers • Task specific web servers
  45. 45. When Everything Goes Wrong
  46. 46. Hire An Amazing SysAdmin
  47. 47. Thank You
  48. 48. Find Me • http://josephscott.org/ • joseph@josephscott.org • http://twitter.com/josephscott/ • #wordpress-dev
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×