SlideShare a Scribd company logo
SCALING WORDPRESS
                          Tips & Tricks




   email: pittaya@gmail.com
   twitter: @pittaya

วันพุธที่ 7 เมษายน 2010
Background

   • I’m       working at MThai.com

   • The        3rd highest traffic website in Thailand

   • Entertainment,         News, Lifestyle portal

   • More          than 500k visitors per day (millions page view)

   • Most          of the website are implemented in wordpress


วันพุธที่ 7 เมษายน 2010
Why wordpress?


   • Quickly              developed

   • Easy         for content team (Compare to other CMS)

   • Highly          customizable

   • Good           enough for most content-based website



วันพุธที่ 7 เมษายน 2010
Problem with wordpress


   • Extensive            use of database

   • Some            page may take up to 50-100 queries

   • Slow          page rendering (a lot of actions, filters)




วันพุธที่ 7 เมษายน 2010
Solution 1


   • Just        throw hardware at it

   • Buy        a bigger, faster box

   • Scale          vertically




วันพุธที่ 7 เมษายน 2010
Solution 2


   • Buy        more boxes

   • Horizontal           scale

   • DNS    load balancing (cheap) or hardware load balancing
      (pretty expensive)




วันพุธที่ 7 เมษายน 2010
Solution 3


   • Caching

   • Disk        or memory

   • Queries              or rendered pages




วันพุธที่ 7 เมษายน 2010
Shared
                                              storage

           Request /
           Response        Load
                                     Apache   MySQL
                          Balancer



                                              Memcac
                                     Apache    hed




วันพุธที่ 7 เมษายน 2010
wp-super-cache


   • Plugin          : wp-super-cache

   • Cache            the whole pages on local disk

   • No       additional software required

   • High         I/O usage for frequently updated site



วันพุธที่ 7 เมษายน 2010
memcached backend


   • Cache            queries, not page

   • Require              memcached

   • Some            queries are not cached (wordpress behavior)




วันพุธที่ 7 เมษายน 2010
batcache

   • Similar              approach to wp-super-cache

        • superman/batman                  - supercache/batcache

   • Store          cached page in memcached

   • Reduce                disk I/O load

   • Not        much documented


วันพุธที่ 7 เมษายน 2010
W3 Total cache


   • Able         to cache pages or queries or both

   • Store          cached data on disk or in memcached

   • Highly          configurable

   • No       problem so far



วันพุธที่ 7 เมษายน 2010
Some tricky part

   • default-filters.php

        • add_action('wp_head',         'start_post_rel_link', 10, 0);

   • Cause            uncached query for every single post/page

        • Ugly        table scan, using filesort query

   • Can         kill your database if your site has high traffic


วันพุธที่ 7 เมษายน 2010
One line to solve it



   • Put       it in your theme’s functions.php

   • remove_action('wp_head',         'start_post_rel_link', 10, 0);




วันพุธที่ 7 เมษายน 2010
Multiple wordpress installations

   • memcached               backend

        • Cache           key collision -> change the global $blog_id

   • wp-super-cache

        • Configure           different cache location

   • W3        total cache

        • Cache           key collision on same domain -> hack

วันพุธที่ 7 เมษายน 2010
Reduce # of HTTP requests

   • Combine               CSS

   • Combine               JavaScript

   • Use         image sprite

   • Cache            static files on user’s side

   • Consult              Google’s PageSpeed / Yahoo’s YSlow document


วันพุธที่ 7 เมษายน 2010
Key idea


   • Don’t          let requests touch the database

   • Keep           disk activity low

   • Scale          horizontally




วันพุธที่ 7 เมษายน 2010
Thank you!

   • If   you want to contact me:

        • pittaya@gmail.com

        • twitter.com/pittaya

        • facebook.com/pittaya

        • www.pittaya.com

   • See        you at BarCamp Bangkok !

วันพุธที่ 7 เมษายน 2010

More Related Content

PPT
Blogging the New Arab Public by Marc Lynch
PPTX
Dialogue
PPT
La radio catalana a Internet 2006 2007
PDF
Fwdder : share your forward mails
PDF
Reading xkcd
PDF
Cooking for guys
KEY
Firefox OS
PDF
Using Apache Solr
Blogging the New Arab Public by Marc Lynch
Dialogue
La radio catalana a Internet 2006 2007
Fwdder : share your forward mails
Reading xkcd
Cooking for guys
Firefox OS
Using Apache Solr
Ad

Scaling Wordpress

  • 1. SCALING WORDPRESS Tips & Tricks email: pittaya@gmail.com twitter: @pittaya วันพุธที่ 7 เมษายน 2010
  • 2. Background • I’m working at MThai.com • The 3rd highest traffic website in Thailand • Entertainment, News, Lifestyle portal • More than 500k visitors per day (millions page view) • Most of the website are implemented in wordpress วันพุธที่ 7 เมษายน 2010
  • 3. Why wordpress? • Quickly developed • Easy for content team (Compare to other CMS) • Highly customizable • Good enough for most content-based website วันพุธที่ 7 เมษายน 2010
  • 4. Problem with wordpress • Extensive use of database • Some page may take up to 50-100 queries • Slow page rendering (a lot of actions, filters) วันพุธที่ 7 เมษายน 2010
  • 5. Solution 1 • Just throw hardware at it • Buy a bigger, faster box • Scale vertically วันพุธที่ 7 เมษายน 2010
  • 6. Solution 2 • Buy more boxes • Horizontal scale • DNS load balancing (cheap) or hardware load balancing (pretty expensive) วันพุธที่ 7 เมษายน 2010
  • 7. Solution 3 • Caching • Disk or memory • Queries or rendered pages วันพุธที่ 7 เมษายน 2010
  • 8. Shared storage Request / Response Load Apache MySQL Balancer Memcac Apache hed วันพุธที่ 7 เมษายน 2010
  • 9. wp-super-cache • Plugin : wp-super-cache • Cache the whole pages on local disk • No additional software required • High I/O usage for frequently updated site วันพุธที่ 7 เมษายน 2010
  • 10. memcached backend • Cache queries, not page • Require memcached • Some queries are not cached (wordpress behavior) วันพุธที่ 7 เมษายน 2010
  • 11. batcache • Similar approach to wp-super-cache • superman/batman - supercache/batcache • Store cached page in memcached • Reduce disk I/O load • Not much documented วันพุธที่ 7 เมษายน 2010
  • 12. W3 Total cache • Able to cache pages or queries or both • Store cached data on disk or in memcached • Highly configurable • No problem so far วันพุธที่ 7 เมษายน 2010
  • 13. Some tricky part • default-filters.php • add_action('wp_head', 'start_post_rel_link', 10, 0); • Cause uncached query for every single post/page • Ugly table scan, using filesort query • Can kill your database if your site has high traffic วันพุธที่ 7 เมษายน 2010
  • 14. One line to solve it • Put it in your theme’s functions.php • remove_action('wp_head', 'start_post_rel_link', 10, 0); วันพุธที่ 7 เมษายน 2010
  • 15. Multiple wordpress installations • memcached backend • Cache key collision -> change the global $blog_id • wp-super-cache • Configure different cache location • W3 total cache • Cache key collision on same domain -> hack วันพุธที่ 7 เมษายน 2010
  • 16. Reduce # of HTTP requests • Combine CSS • Combine JavaScript • Use image sprite • Cache static files on user’s side • Consult Google’s PageSpeed / Yahoo’s YSlow document วันพุธที่ 7 เมษายน 2010
  • 17. Key idea • Don’t let requests touch the database • Keep disk activity low • Scale horizontally วันพุธที่ 7 เมษายน 2010
  • 18. Thank you! • If you want to contact me: • pittaya@gmail.com • twitter.com/pittaya • facebook.com/pittaya • www.pittaya.com • See you at BarCamp Bangkok ! วันพุธที่ 7 เมษายน 2010