際際滷

際際滷Share a Scribd company logo
Screaming Fast Wordpress




Dan Collis-Puro
Berkman Center for Internet & Society
http://blogs.law.harvard.edu/djcp
djcp@cyber.law.harvard.edu
Me

Dev/sysadmin for 12 years
Pro linux admin 9 years

Perl / mod_perl / postgres / mysql / ruby / rails /

php
Mostly scrappy non-profits

Geek-of-all-trades at Berkman (

http://cyber.law.harvard.edu)
http://blogs.law.harvard.edu/

Help manage many servers and

apps
Goals

Use minimum resources to fulfill requests
Survive the slashdot/digg effect

Unobtrusive

Easy to tune

Optimize for different platforms / audiences

If you hit the app server, you've failed

If you MUST hit the app server, do

what's reasonable to minimize
resources
MLAPW



MySQL
Linux

Apache

PHP

Wordpress
MySQL

Optimize tables (with mysqlcheck and a cron job)
Bump up query cache

Tune key buffers

mysqltuner.pl / tuning-primer.sh

Might want more indexes, depending

mytop

Slow query log

(meh) Clean out options table

(meh) Clean out revisions / old spam

(plugin) debug-queries
Linux



RAM
Never use swap

Fast disk, database on its own spindles

Fast network

stat() kills you on network filesystems
Apache


Use a reverse proxy
Keepalive on frontend, no keepalive on backend

Enable mod_deflate

Set a sane MaxClients setting

Use a lighter-weight frontend server  nginx!

Use frontend proxy caching

apachetop
PHP



Enable opcode cache
Make sure you allocate enough

shared RAM
Consider not allowing stat()s
Good / bad apc
Good          Bad
Wordpress


Two major audiences: logged in and not.
WP-SuperCache, W3 Total Cache

Memcached is not a panacea.

Nor is the WP object cache.

Disable unused plugins

CDN for media delivery
Our Problem


750+ live blogs, some heavily trafficked and quite
large
Not too many simulateously auth'd users

MANY spiders. Freakin' spiders!

Mini-DDOSs each week

ENORMOUS corpus of URLs to cache

RSS feeds don't use feedburner
Our Solution

nginx as a caching front-end proxy
No plugins

4 lines of code to the wordpress core

Very flexible caching rules

Able to cache for both audiences (sorta)

Able to cache EVERYTHING. Period.

Handles gzipping and logging

Able to kill bad 'bots
Results

Almost NO problems since implementation
Atom feed from 6/sec to 2500/sec (network test)

Atom feed from 3.95/sec to ~7000/sec (local test)

(apache 3500 / sec)
DOUBLED network throughput (?)

Halved memory requirements

Able to rip out all wordpress-level

customizations and plugins.
Except one.
Screaming Fast Wpmu
Random Tools

ab + bash
firebug

yslow

Siege

htop

apachetop

mysqltop

EXPLAIN select
Photo credits:
Characters:
http://www.flickr.com/photos/goopymart

Background:
http://www.flickr.com/photos/roll_initiative

I  you! Get in touch:
http://blogs.law.harvard.edu/djcp
djcp on the twitterz
djcp@cyber.law.harvard.edu
dan@collispuro.com
http://delicious.com/djcp - more specifically:
http://delicious.com/djcp/screamingfastwp

More Related Content

Screaming Fast Wpmu

  • 1. Screaming Fast Wordpress Dan Collis-Puro Berkman Center for Internet & Society http://blogs.law.harvard.edu/djcp djcp@cyber.law.harvard.edu
  • 2. Me Dev/sysadmin for 12 years Pro linux admin 9 years Perl / mod_perl / postgres / mysql / ruby / rails / php Mostly scrappy non-profits Geek-of-all-trades at Berkman ( http://cyber.law.harvard.edu) http://blogs.law.harvard.edu/ Help manage many servers and apps
  • 3. Goals Use minimum resources to fulfill requests Survive the slashdot/digg effect Unobtrusive Easy to tune Optimize for different platforms / audiences If you hit the app server, you've failed If you MUST hit the app server, do what's reasonable to minimize resources
  • 5. MySQL Optimize tables (with mysqlcheck and a cron job) Bump up query cache Tune key buffers mysqltuner.pl / tuning-primer.sh Might want more indexes, depending mytop Slow query log (meh) Clean out options table (meh) Clean out revisions / old spam (plugin) debug-queries
  • 6. Linux RAM Never use swap Fast disk, database on its own spindles Fast network stat() kills you on network filesystems
  • 7. Apache Use a reverse proxy Keepalive on frontend, no keepalive on backend Enable mod_deflate Set a sane MaxClients setting Use a lighter-weight frontend server nginx! Use frontend proxy caching apachetop
  • 8. PHP Enable opcode cache Make sure you allocate enough shared RAM Consider not allowing stat()s
  • 9. Good / bad apc Good Bad
  • 10. Wordpress Two major audiences: logged in and not. WP-SuperCache, W3 Total Cache Memcached is not a panacea. Nor is the WP object cache. Disable unused plugins CDN for media delivery
  • 11. Our Problem 750+ live blogs, some heavily trafficked and quite large Not too many simulateously auth'd users MANY spiders. Freakin' spiders! Mini-DDOSs each week ENORMOUS corpus of URLs to cache RSS feeds don't use feedburner
  • 12. Our Solution nginx as a caching front-end proxy No plugins 4 lines of code to the wordpress core Very flexible caching rules Able to cache for both audiences (sorta) Able to cache EVERYTHING. Period. Handles gzipping and logging Able to kill bad 'bots
  • 13. Results Almost NO problems since implementation Atom feed from 6/sec to 2500/sec (network test) Atom feed from 3.95/sec to ~7000/sec (local test) (apache 3500 / sec) DOUBLED network throughput (?) Halved memory requirements Able to rip out all wordpress-level customizations and plugins. Except one.
  • 15. Random Tools ab + bash firebug yslow Siege htop apachetop mysqltop EXPLAIN select
  • 16. Photo credits: Characters: http://www.flickr.com/photos/goopymart Background: http://www.flickr.com/photos/roll_initiative I you! Get in touch: http://blogs.law.harvard.edu/djcp djcp on the twitterz djcp@cyber.law.harvard.edu dan@collispuro.com http://delicious.com/djcp - more specifically: http://delicious.com/djcp/screamingfastwp