18
SCALING WORDPRESS Tips & Tricks email: [email protected] twitter: @pittaya วันพุธที่ 7 เมษายน 2010

Scaling Wordpress

  • Upload
    pittaya

  • View
    2.446

  • Download
    2

Embed Size (px)

DESCRIPTION

Tips & tricks for scaling wordpress

Citation preview

Page 1: Scaling Wordpress

SCALING WORDPRESSTips & Tricks

email: [email protected]: @pittaya

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

Page 2: Scaling Wordpress

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

Page 3: Scaling Wordpress

Why wordpress?

• Quickly developed

• Easy for content team (Compare to other CMS)

• Highly customizable

• Good enough for most content-based website

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

Page 4: Scaling Wordpress

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

Page 5: Scaling Wordpress

Solution 1

• Just throw hardware at it

• Buy a bigger, faster box

• Scale vertically

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

Page 6: Scaling Wordpress

Solution 2

• Buy more boxes

• Horizontal scale

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

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

Page 7: Scaling Wordpress

Solution 3

• Caching

• Disk or memory

• Queries or rendered pages

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

Page 8: Scaling Wordpress

Apache

Memcached

MySQLLoad

Balancer

Request /Response

Shared storage

Apache

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

Page 9: Scaling Wordpress

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

Page 10: Scaling Wordpress

memcached backend

• Cache queries, not page

• Require memcached

• Some queries are not cached (wordpress behavior)

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

Page 11: Scaling Wordpress

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

Page 12: Scaling Wordpress

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

Page 13: Scaling Wordpress

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

Page 14: Scaling Wordpress

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

Page 15: Scaling Wordpress

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

Page 16: Scaling Wordpress

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

Page 17: Scaling Wordpress

Key idea

• Don’t let requests touch the database

• Keep disk activity low

• Scale horizontally

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

Page 18: Scaling Wordpress

Thank you!

• If you want to contact me:

[email protected]

• twitter.com/pittaya

• facebook.com/pittaya

• www.pittaya.com

• See you at BarCamp Bangkok !

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