wordpress performance & scalability

Post on 24-Apr-2015

17.824 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

WordPress Performance and Scalability

Joseph Scotthttp://joseph.randomnetworks.com/

Thursday 28 August 2008Utah Open Source Conference

WordCamp Utah

http://utah.wordcamp.org

Saturday 27 September 2008Provo, Utah (Novell)

Minimize Context Switches

Ask on topic questions (clarification)as we go along

No, Seriously,Backup First

Performance

How fast is a single request?

ScalabilityDealing with many requests at the same time

It’s Like An Onion

• WordPress

• MySQL / Memcache

• PHP

• Web server

• Network / Operating System

Network /Operating System

Tweak for your traffic

Look at TCP buffers and kernel enhancements(kqueue/epoll)

Web ServerApache? There are others:

•lighttpd•nginx•LiteSpeed (free/commercial)•Zeus (commercial)

Apache

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

• Turn off host name lookups

• Do you use symlinks? (turn off FollowSymLinks)

• Serve static content from another server (not Apache?)

PHP

• Compiler Cache (APC)

• Output buffering

• Minimize system calls

• Be careful with preg_* functions

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

MySQL• Table types

• MyISAM - high writes or reads, not both

• InnoDB - efficient locking, better concurrency

• Double and triple check indexes

• Tune your config (key_buffer_size, innodb_buffer_pool_size, query_cache_size, thread_cache, table_cache, etc)

• Interesting quirks, get familiar with them

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

But be careful

WordPress

• MySQL tables default to MyISAM, consider switching some to InnoDB (wp_comments)

• Serve static content from another server

• Add caching plugins and throw more hardware at the problem

Does WordPress Scale?http://wordpress.com/stats/traffic/

Lets start from the basics and work our way up

Test Environment

• FreeBSD 7

• Apache 2.2.8

• PHP 5.2.6

• MySQL 5.0.51a

• WordPress 2.6.1

Test “Hardware”

• Parallels VM on Mac Pro

• 1GB Ram

• 1 Xeon 2.66

ab - Apache HTTP server benchmarking tool

ab -n 150 -c 15 http://192.168.1.115/wp/2.6.1/archives/1

Only worried about the fastest results, we want to see what’s possible

The Base Line

Zero byte HTML file (null.html)1480 r/s

APCZero byte PHP file (null.php)

Without APC: 1290 r/sWith APC: 1359 r/s

We’ll see bigger differences later

Hi There!

helloworld.html (13 bytes) - 1382 r/s

helloworld.php (<?php print "Hello World!"; ?>)

Without APC: 1283 r/sWith APC: 1348 r/s

More Unrealistic Numbers

Static version of archives/1 (5147 bytes)1027 r/s

Fun With Math•1027 r/s•1027 * 86,400 = 88,732,800 r/d

Requests != Page Views

7 request-able objects in archives/1 88,732,800 / 7 = 12,676,114 pv/d

Real average number of objects is closer to 5088,732,800 / 50 = 1,774,656 pv/d

WordPress 2.6.1

WordPress 2.6.1

Default Template - archives/1 (Hello World! post with one comment)17 queries

Without APC: 8 r/s / ~0.130s per pageWith APC: 38 r/s / ~0.025s per page

Use a compiler cache, it’s like free money!

WP Super Cache

• Plugin by Donncha O Caoimh (WPMU lead developer)

• Uses the advanced caching capabilities of WP to store complete versions of pages to disk

• Requires the web server to have write access to wp-content/cache

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

APC + WP Super Cache

Default Template - archives/1 (Hello World! post with one comment)

APC + WP Super Cache: 338 r/swith compression: 459 r/s

Kind of like printing money

Memcache & WordPress

• Written by Ryan Boren (WP lead developer)

• Stores database results and WordPress objects in memcache

• Reduces the number of database queries

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

APC + Memcache

Default Template - archives/1 (Hello World! post with one comment)4 queries

APC + Memcache: 41 r/s / ~0.022s per page

Batcache!

Batcache

• Written by Andy Skelton (WP contributing developer)

• Like WP Super Cache, only stores rendered pages in memcache instead of to disk

• Builds on top of Ryan’s memcache code

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

APC + Memcache/Batcache

Default Template - archives/1 (Hello World! post with one comment)

APC + Memcache/Batcache: 449 r/s

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

Extras Requests per second

Page Generation

TimeNone 8 ~0.12s

APC 38 ~0.025s

APC + WP Super Cache

338 N/A

APC + WP Super Cache

+Compression459 N/A

APC + Memcache 41 ~0.022s

APC + Memcache +

Batcache449 N/A

What does all of this mean in real life?

Phase 1

Phase 2

Phase 3

A Good Start.But Wait, There’s More!

MySQL Replication• Master/Slave - one-way asynchronous

replication

• Send writes to the master, reads to the slave

• Replication works with all tables types

• One master can support any number of slaves

• Fairly easy to setup

Enter HyperDB• Drop in replacement for the standard

WordPress database class

• Supports distributed read/writes (database replication - master/slave)

• Can partition data (helpful for large WPMU installs)

• Will failover to other database servers via multiple routes

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

Phase 4

If You Call Now....

You’ll get web server load balancing too

Phase 5

Why This Works

No server side session storage

Variations on a Theme

• Master/Relay/Slaves

• Slave just for backups

• Multiple data centers

• Multiple Memcache servers

• Separate web servers for front end and back end

Things Start To Get Interesting

WordPress as an application platform

Questions?

top related