Coding, Scaling, and Deploys... Oh My!

43
Coding Scaling and Deploys Mark Jaquith “JAKE-with” @markjaquith [email protected] markjaquith.com Oh My! Friday, August 12, 11

description

You're a professional WordPress developer in charge of a professional WordPress site. It's time to have professional development and deployment practices.

Transcript of Coding, Scaling, and Deploys... Oh My!

Page 1: Coding, Scaling, and Deploys... Oh My!

CodingScaling

andDeploys

Mark Jaquith“JAKE-with”

@[email protected] Oh My!

Friday, August 12, 11

Page 2: Coding, Scaling, and Deploys... Oh My!

Photo by Sco! Beale (Laughing Squid)

Meanwhile, in 2006...

Friday, August 12, 11

Page 3: Coding, Scaling, and Deploys... Oh My!

CowboyCoding

Friday, August 12, 11

Page 4: Coding, Scaling, and Deploys... Oh My!

CowboyCoding

BAD DEVELOPER! BAD!

Friday, August 12, 11

Page 5: Coding, Scaling, and Deploys... Oh My!

bnj.com/cowboy-coding-pink-sombrero

Friday, August 12, 11

Page 6: Coding, Scaling, and Deploys... Oh My!

VCS GTFO• or •

Friday, August 12, 11

Page 7: Coding, Scaling, and Deploys... Oh My!

WordPressin your repo

Friday, August 12, 11

Page 8: Coding, Scaling, and Deploys... Oh My!

My Ideal index.phpwp-config.phpcontent/themes/content/plugins/content/uploads/ (ignored)

wp ➠ EXTERNAL

Friday, August 12, 11

Page 9: Coding, Scaling, and Deploys... Oh My!

Local Development

Friday, August 12, 11

Page 10: Coding, Scaling, and Deploys... Oh My!

1. MAMP, XAMPP, other

2. /etc/hosts

3. local-config.php

Friday, August 12, 11

Page 11: Coding, Scaling, and Deploys... Oh My!

if ( file_exists( dirname( __FILE__ ) . '/local-config.php' ) ) { include( dirname( __FILE__ ) . '/local-config.php' ); define( 'WP_LOCAL_DEV', true );} else { define( 'WP_LOCAL_DEV', false ); define( 'DB_NAME', 'production_db' ); define( 'DB_USER', 'production_user' ); define( 'DB_PASSWORD', 'production_password' ); define( 'DB_HOST', 'production_db_host' );}

Ignore local-config.php so it doesn’t get checked in.

Friday, August 12, 11

Page 12: Coding, Scaling, and Deploys... Oh My!

Deploying — with —

Friday, August 12, 11

Page 13: Coding, Scaling, and Deploys... Oh My!

1. gem install capistrano

2. gem install railsless-deploy

3. gem install capistrano-ext

Friday, August 12, 11

Page 14: Coding, Scaling, and Deploys... Oh My!

releases/

current => {current-release}

shared/cached-copy

shared/files/

Friday, August 12, 11

Page 15: Coding, Scaling, and Deploys... Oh My!

checked in:content/uploads => ../../files/uploads/

done on deploy:files => /srv/www/example.org/shared/files/

Friday, August 12, 11

Page 16: Coding, Scaling, and Deploys... Oh My!

Scaling a Single Server

Friday, August 12, 11

Page 17: Coding, Scaling, and Deploys... Oh My!

nginxFriday, August 12, 11

Page 18: Coding, Scaling, and Deploys... Oh My!

proxy to Apacheor

PHP-FPMFriday, August 12, 11

Page 19: Coding, Scaling, and Deploys... Oh My!

PHPOpcode Cache

Friday, August 12, 11

Page 20: Coding, Scaling, and Deploys... Oh My!

WP Object Cache

Friday, August 12, 11

Page 21: Coding, Scaling, and Deploys... Oh My!

HTMLOutputCache

Batcache || W3 Total Cache

Friday, August 12, 11

Page 22: Coding, Scaling, and Deploys... Oh My!

Fragment Caching

if ( $html = wp_cache_get( 'expensive-html-chunk', 'my-theme' ) ) { echo $html;} else { $html = dynamically_generate_foo(); wp_cache_set( 'expensive-html-chunk', $html, 'my-theme', 3600 ); echo $html;}

Friday, August 12, 11

Page 23: Coding, Scaling, and Deploys... Oh My!

MySQL Query Cache

Friday, August 12, 11

Page 24: Coding, Scaling, and Deploys... Oh My!

CDN— with —

Origin PullFriday, August 12, 11

Page 25: Coding, Scaling, and Deploys... Oh My!

The Plan

Friday, August 12, 11

Page 26: Coding, Scaling, and Deploys... Oh My!

What happens if we outgrow our server?

Boss

Tech

The Plan

Friday, August 12, 11

Page 27: Coding, Scaling, and Deploys... Oh My!

What happens if we outgrow our server?

Boss

Tech

We’ll just add new servers!

The Plan

Friday, August 12, 11

Page 28: Coding, Scaling, and Deploys... Oh My!

What happens if we outgrow our server?

Brilliant!

Boss

Tech

We’ll just add new servers!

The Plan

Friday, August 12, 11

Page 29: Coding, Scaling, and Deploys... Oh My!

The Plan

Friday, August 12, 11

Page 30: Coding, Scaling, and Deploys... Oh My!

The Reality

Friday, August 12, 11

Page 31: Coding, Scaling, and Deploys... Oh My!

Our site is slow. Let’s add another server.

Boss

Tech

The Reality

Friday, August 12, 11

Page 32: Coding, Scaling, and Deploys... Oh My!

Our site is slow. Let’s add another server.

Boss

Tech

Uh...

The Reality

Friday, August 12, 11

Page 33: Coding, Scaling, and Deploys... Oh My!

Our site is slow. Let’s add another server.

So this will take like 5 minutes, right?

Boss

Tech

Uh...

The Reality

Friday, August 12, 11

Page 34: Coding, Scaling, and Deploys... Oh My!

Have a plan

Not an ideaFriday, August 12, 11

Page 35: Coding, Scaling, and Deploys... Oh My!

Multiple Servers

Friday, August 12, 11

Page 36: Coding, Scaling, and Deploys... Oh My!

Load Balancing

Friday, August 12, 11

Page 37: Coding, Scaling, and Deploys... Oh My!

Sharing Uploads

Friday, August 12, 11

Page 38: Coding, Scaling, and Deploys... Oh My!

Memcached

Friday, August 12, 11

Page 39: Coding, Scaling, and Deploys... Oh My!

Rinse & Repeat

Friday, August 12, 11

Page 40: Coding, Scaling, and Deploys... Oh My!

HyperDB

Friday, August 12, 11

Page 41: Coding, Scaling, and Deploys... Oh My!

MaintainingServers with

PuppetFriday, August 12, 11

Page 42: Coding, Scaling, and Deploys... Oh My!

This is the start of a larger conversation

Friday, August 12, 11

Page 43: Coding, Scaling, and Deploys... Oh My!

Thanks!Mark Jaquith“JAKE-with”

@[email protected]

Friday, August 12, 11