Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
To a thousand servers and beyond: scaling a massive PHP application
Nikolay Bachiyski
February 25, 2012
Programming
3
900
To a thousand servers and beyond: scaling a massive PHP application
Stories of abstraction and scaling WordPress.com. And what they have in common.
Nikolay Bachiyski
February 25, 2012
Tweet
Share
More Decks by Nikolay Bachiyski
See All by Nikolay Bachiyski
nb
0
170
nb
3
410
nb
2
690
nb
2
260
nb
4
6.7k
nb
2
120
nb
3
150
nb
0
91
Other Decks in Programming
See All in Programming
akkeylab
0
330
shigeruoda
0
460
yumcyawiz
4
610
freekmurze
0
200
nauleyco
0
200
manfredsteyer
PRO
0
250
taoshotaro
1
360
yaamaa
0
410
akatsukinewgrad
0
150
decoc
1
320
supikiti
3
1.3k
nrslib
20
13k
Featured
See All Featured
destraynor
146
19k
lara
16
2.6k
sugarenia
233
830k
robhawkes
52
2.8k
reverentgeek
27
1.9k
qrush
285
18k
smashingmag
283
47k
jcasabona
7
520
marcelosomers
220
15k
jonrohan
1021
380k
yeseniaperezcruz
302
31k
malarkey
393
60k
Transcript
To 1000 servers and beyond Nikolay Bachiyski PHPUK 2012
http://extrapolate.me/ @nikolayb
None
None
None
Stinson Beach, July 2007
Budapest, Oct 2011
Jul, 2007 65MM Feb, 2011 800MM PV
2 stories
Story #1
Deep Pink Meet
Don’t like?
Beer Beheader =
None
None
Abstraction
None
Beer Theory
None
Want to be better?
Get to know the abstraction below
Servers are below
Story #2 Scaling WordPress.com
None
X
Deep Pink SAD
None
X
Deep Pink SAD
None
None
Users Blogs Blogs
No joins :(
None
SELECT * FROM wp_users WHERE id=43315 SELECT * FROM wp_posts
LIMIT 10
HyperDB
None
SELECT * FROM wp_users WHERE id=43315
Query parsing
add_db_table('user', 'wp_users') Dataset Table name
add_db_server('user', 0, 1, 0,
'db42.wordpress.com',…) Dataset Partition Read Write Slave
Failover X
Can work without
http://wordpress.org/extend/plugins/hyperdb/
None
None
C C C C
$count = wp_cache_get('posts', 'counts'); if ( false !== $count )
return $count; $count = $wpdb-‐>get_results($complex_query);
Output caching
10% 90% reads writes
C C C C
C C C C
Deep Pink SAD
Datacenter
C C sane sane
C C crazy sane Update
C C crazy sane Stale!
C C crazy crazy
Deploy
trunk/
Branch in code
~100 commits a day
~100 deploys a day
to ~1000 servers
One-click
None
Fast!
wpdev@nikolay:~$ deploy wpcom Going to update from 47127 to 47128
Syncing wpcom SVN Mirrors ORD (0s)... LUV (0s)... SAT (0s)... Deploying wpcom revision 47128 ORD (3s)... SAT (5s)... LUV (6s)... Revision 47128 successfully deployed (8s)
None
None
Yeah, immediately!
Push to twitter
Push to Facebok
Stats
Spam checks
Index for search
Invalidate caches
Publish the post
ASYNC JOBS
None
$job_id = queue_async_job($data, 'encode_video');
Priorities
Deferred jobs
None
PHP & MySQL
http://code.trac.wordpress.org/wiki/JobsDocs http://code.trac.wordpress.org/browser/jobs
Integration
Hacking
None