roy foubister (hosting high traffic sites on a tight budget)

29
Hosting High Traffic Sites on a tight Budget on a tight Budget or Getting ONE server to stay up while you are able to get a good night’s sleep!

Upload: wordcamp-cape-town

Post on 01-Jul-2015

1.993 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Roy foubister (hosting high traffic sites on a tight budget)

Hosting High Traffic Siteson a tight Budgeton a tight Budgetor

Getting ONE server to stay up while you are able to get a good night’s

sleep!

Page 2: Roy foubister (hosting high traffic sites on a tight budget)

Who is this guy?

Page 3: Roy foubister (hosting high traffic sites on a tight budget)

A little story : keo.co.za

- 28k comments a month- Peaked at 58k

Page 4: Roy foubister (hosting high traffic sites on a tight budget)

Ryan Allen's 12.4 step process

- 20 blogs - 850,000+ pages a day - 25 million / month

Page 5: Roy foubister (hosting high traffic sites on a tight budget)

Whats the point

- Getting a server to use a 3rd of the resources- Delivering 5 x the amount of pages

Page 6: Roy foubister (hosting high traffic sites on a tight budget)

The brief

Big publishing client - social site “next big thing”

- Image - Music - Video

- Must be fast - 99% uptime - Easy to maintain

Page 7: Roy foubister (hosting high traffic sites on a tight budget)

The development

Wire frames > design > development

The dev goes smooth on a local dev box

Client says right make it live.

Page 8: Roy foubister (hosting high traffic sites on a tight budget)

Production Server

Order the linux server from the hosting co.

Ubuntu 11.04 installed with LAMP - Sounds great!!

Sounds good, right - Linux can handle anything, its the greatest thing since duck tape!

The media release goes out and the people start flooding to the site.

Page 9: Roy foubister (hosting high traffic sites on a tight budget)

CRASH

Oh hell - the sites response is slow“Duck it” the site is down!!!

You try connect to it with SSH - nothing, no pings - IT'S GONE!

Call the hosting company - please hard reboot our server :|

Client breathing fire your way!

Page 10: Roy foubister (hosting high traffic sites on a tight budget)

WTF just happened?

Hardware resources are finite - the default install of LAMP will let you down under load.

Resource bottle necks

CPU - Dynamic generated pages, mysqlMemory - PHP, cache, mysqlDisk - Files, static content, file pointersNetwork - Static content, dynamic content

Page 11: Roy foubister (hosting high traffic sites on a tight budget)

Make it simple!

Optimizing can get out of control, some simple changes can make a big difference.

- Use products that have community support - Use products that are expected by by your team

Think about the full process from server to rendering in the browser.

Page 12: Roy foubister (hosting high traffic sites on a tight budget)

12

Test Server time

- Ubuntu 11.04 install - Intel Pentium Dual CPU E2180 @ 2.00GHz / 4Gb ram - PHP 5.3 / MYSQL 5.1 - WordPress 3.2.1 - Twentyeleven default theme / WP theme test data

Please send donations for new test server equipment!!! :)

Page 13: Roy foubister (hosting high traffic sites on a tight budget)

Apache

Default install of Apache-prefork max clients = 150 (can set up to 256 before having to recompile)

mod_php

Keep alive default is 15 - set it to 5 seconds!

Apache ready

Options: - apache-worker with php on fast-cgi - have fun!

Page 14: Roy foubister (hosting high traffic sites on a tight budget)

Mysql

Default settings - new versions of Ubuntu have query cache turned on - this saved my butt on keo.co.za

MyISAM or InnoDB = WP performance almost the same with query cache turned on!

Mysql ready

Very cool Mysql tuning scripts on git hub - help set the settings from reading your server stats.

Page 15: Roy foubister (hosting high traffic sites on a tight budget)

Hammer time

# ab -k -n1000 -c150 http://wptest.dev/index.php

Apache bench - comes with apache.

-n 1000 hit the site 1000 times!-c 150 concurrent hits (apache max clients at 150)

-k try set keep alive

Page 16: Roy foubister (hosting high traffic sites on a tight budget)

Warning : load 108! What??

Got 12 pages/sec out in 81 seconds, Load?

Page 17: Roy foubister (hosting high traffic sites on a tight budget)

APC to the rescue. Not...

OK, lets OP cache - preprocess all the PHP scripts and cache them in machine code.

hmmm - run test -> load spikes to 104 -> 12 pages/sec

Not much help

(I know there is more to APC - but not fresh install!!)

Page 18: Roy foubister (hosting high traffic sites on a tight budget)

Jump Tests!!!

- Get system stats?

- I only have one Hard drive in the server

– What if its a disk IO issue?

Page 19: Roy foubister (hosting high traffic sites on a tight budget)

RAM drive

This is not an installation procedure!

Create copy files over to memory drive - Be brave and run this in production - Shoot your self in the foot - Feels the same?

Page 20: Roy foubister (hosting high traffic sites on a tight budget)

Got it - load 40 @ 53 req/s

Blazing fast performance!

Same task completed in 17 seconds - 400% improvement!!!

Now do it in a safe way! WP pick your cache!!!

WP CACHEWP SUPER CACHEW3 TOTAL CACHE

What to name the next cache!!!

Page 21: Roy foubister (hosting high traffic sites on a tight budget)

w3 Total cache

This was suggested by the Joyent cloud developers

Options - - Object - Pages - etc.....

Remove the Ram drive, install and activate just object cache,

Server load 40 @ 40 req/s - finished in 24 seconds..... nice

Page 22: Roy foubister (hosting high traffic sites on a tight budget)

Cache’ing out!

Turned on the total cache

- objects, pages, etc....

Server load 33 @ 61 req/s

- finished in 16 seconds..... Blistering!!!

500% improvement!!!

Page 23: Roy foubister (hosting high traffic sites on a tight budget)

The change

Page 24: Roy foubister (hosting high traffic sites on a tight budget)

Split off static content

Simple - define content url in the wp-config.php

Page 25: Roy foubister (hosting high traffic sites on a tight budget)

Nginx & DNS

- Bind to second IP on the same server - webroot to the same as apache webroot - return all media files.

Page 26: Roy foubister (hosting high traffic sites on a tight budget)

Gain?

- 1 call to Apache - PHP - 8 calls to Nginx - no cookie, no resource hit!

Page 27: Roy foubister (hosting high traffic sites on a tight budget)

27

Next step - Nginx proxy??

Setup Nginx to proxy dynamic calls to Apache on localhost and deliver static content itself.

Caution - plugins and client IP addresses.... Test, Test, etc....

Page 28: Roy foubister (hosting high traffic sites on a tight budget)

Simplicity, don’t over do it!

Page 29: Roy foubister (hosting high traffic sites on a tight budget)

Thank you! Any Questions?

FormFunction Digital Consultants (Pty) Ltd+27 21 462 0257

www.twitter.com/formfunctionwww.formfunction.co.za

Roy [email protected]: roy-osoutsource

twitter.com/fobroster