High Performance Wordpress

5,596 views

Published on

My presentation from Wordconf 2011 about High Performance Wordpress. Covers tuning the whole LAMP stack, some stuff on Wordpress and Caching (both plugins and Varnish).

Published in: Technology, Business
1 Comment
7 Likes
Statistics
Notes
No Downloads
Views
Total views
5,596
On SlideShare
0
From Embeds
0
Number of Embeds
2,159
Actions
Shares
0
Downloads
50
Comments
1
Likes
7
Embeds 0
No embeds

No notes for slide

High Performance Wordpress

  1. 1. High Performance WordPress <ul><li>Gareth Davies </li></ul>
  2. 2. Why performance? <ul><li>Speed </li></ul><ul><ul><li>so people don’t wait </li></ul></ul><ul><li>Scale </li></ul><ul><ul><li>serve as many requests to as many people as possible, concurrently </li></ul></ul>
  3. 3. LAMP <ul><li>A stack </li></ul><ul><li>LAMP </li></ul><ul><ul><li>Linux </li></ul></ul><ul><ul><li>Apache </li></ul></ul><ul><ul><li>MySQL </li></ul></ul><ul><ul><li>PHP </li></ul></ul>
  4. 4. WordPress <ul><li>Written in PHP </li></ul><ul><li>Uses MySQL as the database </li></ul><ul><li>Apache/nginx can be used for HTTP </li></ul>
  5. 5. WordPress <ul><li>Core (installed) </li></ul><ul><li>Themes </li></ul><ul><li>Plugins </li></ul>
  6. 6. OS Level Tuning <ul><li>You’re 64-bit by now </li></ul><ul><li>Log errors, and nothing else </li></ul><ul><li>TCP/IP settings </li></ul><ul><li>Only run services that you need on a server </li></ul>
  7. 7. OS Level Tuning <ul><li>Simple firewall to stop bots </li></ul><ul><li>Read log files from logwatch -- hardware dies too </li></ul><ul><li>vmem.sh </li></ul><ul><li>Filesystem - XFS is best, EXT3, EXT4 are OK too </li></ul>
  8. 8. Apache <ul><li>Tune Apache (httpd.conf) </li></ul><ul><li>ab & httperf </li></ul><ul><li>MaxClients </li></ul><ul><li>Defaults are usually horrible </li></ul>
  9. 9. MySQL <ul><li>Defaults are terrible, use my.cnf </li></ul><ul><li>mysqltuner.pl, tuningprimer.sh </li></ul><ul><li>mytop </li></ul><ul><li>Use maatkit + mk-query-digest </li></ul><ul><li>See general & slow query log (for your plugin problems) </li></ul><ul><li>InnoDB is better for concurrency, though by default you’re probably using MyISAM </li></ul><ul><li>mysqlslap for benchmarking </li></ul>
  10. 10. PHP <ul><li>Memory settings </li></ul><ul><li>Opcode cache </li></ul><ul><ul><li>XCache, EAccelerator, APC </li></ul></ul><ul><li>php.ini </li></ul>
  11. 11. WordPress <ul><li>Plugins are often horribly coded </li></ul><ul><li>Themes can have direct calls to the database </li></ul>
  12. 12. WordPress <ul><li>Look at wp_options tables </li></ul><ul><li>Disable plugins </li></ul><ul><li>Try the new Twenty Ten theme </li></ul><ul><li>wp_config.php: WP_HOME, WP_SITEURL </li></ul>
  13. 13. Still struggling? <ul><li>Content Delivery Networks (CDN) </li></ul><ul><li>Minify </li></ul><ul><li>Caching </li></ul>
  14. 14. WP Caches <ul><li>WP Super Cache </li></ul><ul><li>W3 Total Cache </li></ul>
  15. 15. More you can do <ul><li>use mod_proxy and serve static content </li></ul><ul><li>CDN: Amazon S3+CloudFront is affordable </li></ul><ul><li>use browser cache (set long expires) </li></ul>
  16. 16. Separate machines <ul><li>2 machines </li></ul><ul><ul><li>web server </li></ul></ul><ul><ul><li>database server </li></ul></ul><ul><li>memcached servers? </li></ul>
  17. 17. Varnish <ul><li>Varnish serves everything from memory </li></ul><ul><li>httpd on a different port, run varnish on port 80 and point it to httpd port </li></ul>
  18. 18. Further growth <ul><li>Its now time to think about MySQL replication (master-slave setups) </li></ul><ul><li>memcached to keep caches of query results (up to 1M) in memory </li></ul><ul><li>HyperDB supports data partitioning, and can read from multiple databases </li></ul>
  19. 19. WordPress.COM <ul><li>several billion HTTP queries per day, billions of MySQL queries too </li></ul><ul><li>HP hardware, all SSD </li></ul>
  20. 20. HipHop from Facebook <ul><li>http://huichen.org/en/2010/06/wordpress-3-benchmark/ </li></ul><ul><li>http://huichen.org/en/2010/06/wordpress-3-benchmark-part-2/ </li></ul><ul><li>~2.7x improvement in performance </li></ul>
  21. 21. Find Me <ul><li>@ShaolinTiger on Twitter </li></ul><ul><li>http://www.shaolintiger.com – My Blog </li></ul><ul><li>shaolintiger at gmail – Email me </li></ul>

×