Upload
pittaya
View
2.446
Download
2
Embed Size (px)
DESCRIPTION
Tips & tricks for scaling wordpress
Citation preview
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
Apache
Memcached
MySQLLoad
Balancer
Request /Response
Shared storage
Apache
วันพุธที่ 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:
• twitter.com/pittaya
• facebook.com/pittaya
• www.pittaya.com
• See you at BarCamp Bangkok !
วันพุธที่ 7 เมษายน 2010