Upload
wordcamp-cape-town
View
1.993
Download
1
Embed Size (px)
Citation preview
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!
Who is this guy?
A little story : keo.co.za
- 28k comments a month- Peaked at 58k
Ryan Allen's 12.4 step process
- 20 blogs - 850,000+ pages a day - 25 million / month
Whats the point
- Getting a server to use a 3rd of the resources- Delivering 5 x the amount of pages
The brief
Big publishing client - social site “next big thing”
- Image - Music - Video
- Must be fast - 99% uptime - Easy to maintain
The development
Wire frames > design > development
The dev goes smooth on a local dev box
Client says right make it live.
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.
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!
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
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.
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!!! :)
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!
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.
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
Warning : load 108! What??
Got 12 pages/sec out in 81 seconds, Load?
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!!)
Jump Tests!!!
- Get system stats?
- I only have one Hard drive in the server
– What if its a disk IO issue?
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?
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!!!
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
Cache’ing out!
Turned on the total cache
- objects, pages, etc....
Server load 33 @ 61 req/s
- finished in 16 seconds..... Blistering!!!
500% improvement!!!
The change
Split off static content
Simple - define content url in the wp-config.php
Nginx & DNS
- Bind to second IP on the same server - webroot to the same as apache webroot - return all media files.
Gain?
- 1 call to Apache - PHP - 8 calls to Nginx - no cookie, no resource hit!
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....
Simplicity, don’t over do it!
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