wordpress performance & scalability

48
WordPress Performance & Scalability Joseph Scott http://josephscott.org/

Upload: joseph-scott

Post on 15-Jan-2015

5.417 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: WordPress Performance & Scalability

WordPressPerformance & Scalability

Joseph Scotthttp://josephscott.org/

Page 2: WordPress Performance & Scalability

Find Me

• http://josephscott.org/

[email protected]

• http://twitter.com/josephscott/

• #wordpress-dev

Page 3: WordPress Performance & Scalability

Backup First

Page 4: WordPress Performance & Scalability

Performance

Shelby Supercars Ultimate Aero Twin Turbo

Page 5: WordPress Performance & Scalability

Scalability

Page 6: WordPress Performance & Scalability

Web Apps Are LikeOgres Onions

Page 7: WordPress Performance & Scalability

Start At The BottomDeal with network problems / bottlenecks first

Be familiar with Operating System network optimizations

Page 8: WordPress Performance & Scalability

Web Server

Apache?

Page 9: WordPress Performance & Scalability

Web Server

nginxhttp://nginx.net/

lighttpdhttp://www.lighttpd.net/

LiteSpeedhttp://litespeedtech.com/

Zeushttp://www.zeus.com/

Page 10: WordPress Performance & Scalability

Apache• Can be a pig, remove any modules you aren’t

using

• Turn off host name lookups

• Turn on compression (mod_deflate)

• Turn off FollowSymLinks (and .htaccess if you can)

• Skip Apache all together, serve static content from another server

Page 11: WordPress Performance & Scalability

PHP

• Use an opcode cache (APC, lots of others)

• Don’t use on static files (unless you really, really need to)

• Consider output buffering

• Be careful with preg_* functions

Page 12: WordPress Performance & Scalability

MySQL - Table TypesMyISAM

• High performance reads or writes, not both

• Full text search

InnoDB

• Better for mixed reads/writes

• Transactions, Foreign Keys

Page 13: WordPress Performance & Scalability

MySQL• Double (and triple) check indexes

• Tune your configuration

• key_buffer_size, table_cache, sort_buffer_size, read_buffer_size

• Replication (more on that later)

• Interesting quirks, get familiar with them

Page 14: WordPress Performance & Scalability

Memcache

In memory object cache, learn it, use it, love it

With Caution

Page 15: WordPress Performance & Scalability

WordPress• MySQL tables default to using MyISAM,

consider using InnoDB instead

• Turn off unused plugins

• Check that themes and plugins aren’t abusing MySQL or PHP

• Server static content from another server (optimized for that task)

Page 16: WordPress Performance & Scalability

Construction

Start from the bottom andwork your way up

Page 17: WordPress Performance & Scalability

Test Setup

• Ubuntu 9.04 server edition

• Apache 2.2.11

• PHP 5.2.6

• MySQL 5.0.75

• WordPress -trunk

Page 18: WordPress Performance & Scalability

Test “Hardware”

Parallels 4.0

2.66 Xeon1 GB Ram

Page 19: WordPress Performance & Scalability

Abusing The Serversiege - http://www.joedog.org/index/siege-home

siege -d 1 -c 50 -r 10 http://192.168.1.100/

Page 20: WordPress Performance & Scalability

Below The Baseline

Zero Byte HTML - zero.html (80 r/s) ~0.01 s/r

Zero Byte PHP - zero.php (80 r/s) ~0.01 s/r

Page 21: WordPress Performance & Scalability

a phpinfo( )’s worth

static HTML - phpinfo.html100% (75 r/s) ~0.04 s/r

PHP - phpinfo.php92% (69 r/s) ~0.04 s/r

51,213 / 8,689 bytes

Page 22: WordPress Performance & Scalability

Hello World!

WordPress: /wp/?p=1

6,582 / 2,531 bytes

Page 23: WordPress Performance & Scalability

Hello World!

WordPress: /wp/?p=18% (6 r/s) ~7 s/r

6,582 / 2,531 bytes

Page 24: WordPress Performance & Scalability

Hello World!+ APC

WordPress: /wp/?p=129% (22 r/s) ~1.51 s/r

Page 25: WordPress Performance & Scalability

Use An Opcode Cache!%8 ~7 %29 ~1.51

Page 26: WordPress Performance & Scalability

Use An Opcode Cache!%8 ~7 %29 ~1.51

Page 27: WordPress Performance & Scalability

WordPress + Memcache

• Ryan Boren

• Stores WordPress data in Memcache

• Reduces the number of database queries

• http://ryan.wordpress.com/2005/12/23/memcached-backend/

Page 28: WordPress Performance & Scalability

Hello World!+ APC + Memcache

WordPress: /wp/?p=132% (24 r/s) ~1.4 s/r

Page 29: WordPress Performance & Scalability

Batcache!

Page 30: WordPress Performance & Scalability

WordPress + Batcache

• Andy Skelton

• Stores rendered HTML in Memcache

• http://wordpress.org/extend/plugins/batcache/

Page 31: WordPress Performance & Scalability

Hello World! + APC + Memcache + Batcache

WordPress: /wp/?p=180% (60 r/s) ~0.4 s/r

Page 32: WordPress Performance & Scalability

Hello World! + APC + Memcache + Batcache

Page 33: WordPress Performance & Scalability

WordPress+ WP Super Cache

• Donncha O Caoimh

• Stores rendered HTML on disk

• http://wordpress.org/extend/plugins/wp-super-cache/

Page 34: WordPress Performance & Scalability

Let me 'splain. ...No, there is too much. Let me sum up.

DescriptionRequests

per SecondSeconds per

request (mean)Potential

Zero Bytes 80 ~0.01 -Static phpinfo() 75 ~0.04 100%phpinfo() 69 ~0.04 92%OOB WP 6 ~7.00 8%WP & APC 22 ~1.51 29%WP & APC/Memcache

24 ~1.40 32%

WP & APC/Memcache/Batcache

60 ~0.04 80%

Page 35: WordPress Performance & Scalability

What Now?

Page 36: WordPress Performance & Scalability

All In One

Web / Database

Page 37: WordPress Performance & Scalability

Moving Out

Web Database

Page 38: WordPress Performance & Scalability

Paying In Cache

Web

DatabaseMemcache

Page 39: WordPress Performance & Scalability

But Wait, There’s More!

Page 40: WordPress Performance & Scalability

MySQL Replication

• Master / Slave - one way asynchronous

• Send writes to the master, reads to the slave(s)

• Replication works on both MyISAM and InnoDB tables

• Supports multiple slaves and replication chaining

Page 41: WordPress Performance & Scalability

Enter HyperDB

• Drop in replacement for the default WordPress database class

• Supports distributed reads/writes

• Partition data (helpful for large WPMU installs)

• Failover support when a database goes down

• http://codex.wordpress.org/HyperDB

Page 42: WordPress Performance & Scalability

Replicated Data

Web

DB Master

MemcacheDB Slave

Page 43: WordPress Performance & Scalability

A Balancing Act

Web 2

Load Balancer

Web 1 Web 3

Page 44: WordPress Performance & Scalability

Variations on a Theme

• Master / Relay / Slave

• Slave just for backups

• Multiple data centers

• Task specific web servers

Page 45: WordPress Performance & Scalability

When Everything Goes Wrong

Page 46: WordPress Performance & Scalability

Hire An Amazing SysAdmin

Page 47: WordPress Performance & Scalability

Thank You

Page 48: WordPress Performance & Scalability

Find Me

• http://josephscott.org/

[email protected]

• http://twitter.com/josephscott/

• #wordpress-dev