Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Designing systems to scale
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Michael Heap
October 06, 2012
Technology
1.6k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Designing systems to scale
Talk given at PHPNW12 in Manchester, England
Michael Heap
October 06, 2012
More Decks by Michael Heap
See All by Michael Heap
WTF are OKRs?
mheap
0
520
But why does the business care?
mheap
0
340
Advanced GitHub Actions
mheap
0
650
Controlling Your Kong Gateway With decK and CI/CD
mheap
0
670
API Standards 2.0
mheap
1
1.2k
API Standards 2.0
mheap
0
670
Dr Sheldon Cooper Presents: Fun with Flags (NEPHP)
mheap
0
750
Dr Sheldon Cooper Presents: Fun with Flags
mheap
0
1.2k
Behat for characterization tests
mheap
0
550
Other Decks in Technology
See All in Technology
「嘘をつくテスト」の失敗例から学ぶ 良いテストコード #frontend_phpcon_do
asumikam
0
510
Platform engineering for developers, architects & the rest of us (AI agents)
danielbryantuk
0
190
製造業のクラウド活用最適解〜AI,DXを加速するデータ基盤の作り方〜
hamadakoji
0
400
AIにフローを作らせようとして挫折した話
hamatsutaichi
0
210
GoとSIMDとWasmの今。
askua
3
510
AI Engineering Summit Tokyo 2026 AIの前に、やることがある 〜医療データ企業の4フェーズ〜
dtaniwaki
0
2k
Mastering Ruby Box
tagomoris
3
150
タクシーアプリ『GO』の実践的データ活用
mot_techtalk
3
160
Amazon Bedrock AgentCore ワークショップ JAWS UG TOHOKU / amazon-bedrock-agentcore-workshop-jawsug-tohoku-2026
gawa
8
350
AgentGatewayを試してみたかった
tkikuchi
0
110
Diagnosing performance problems without the guesswork
elenatanasoiu
0
170
Cloud Run のアップデート 触ってみる&紹介
gre212
0
320
Featured
See All Featured
Tell your own story through comics
letsgokoyo
1
950
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
720
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
The browser strikes back
jonoalderson
0
1.1k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
240
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
The Curse of the Amulet
leimatthew05
1
13k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
190
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
320
Transcript
Designing Systems To Scale
I’m Michael
I’m @mheap I’m Michael
I’m absolutely terrified I’m @mheap I’m Michael
Designing Systems To Scale
Designing Systems To Scale
Designing Systems To Scale
Write programs that do one thing and do it well.
Write programs to work together. Write programs to handle text streams, because that is a universal interface. - Doug McIlroy
Do one thing, and do it well
None
V1
V1 • Codeigniter Application
V1 • Codeigniter Application • No (working) indices on the
database
V1 • Codeigniter Application • No (working) indices on the
database • Used the REST API and pulled data on demand
V1 • Codeigniter Application • No (working) indices on the
database • Used the REST API and pulled data on demand • PHP for realtime parsing
V1 • Codeigniter Application • No (working) indices on the
database • Used the REST API and pulled data on demand • PHP for realtime parsing • All stored in one git repo
24 Users
V1 • Codeigniter Application • No (working) indices on the
database • Used the REST API and pulled data on demand • PHP for realtime parsing • All stored in one git repo
V2
V2 • Decoupled
V2 • Decoupled • Made up of five “apps”
V2 • Decoupled • Made up of five “apps” •
Easier to scale
V2 • Decoupled • Made up of five “apps” •
Easier to scale • More fault tolerant
MySQL Twitter Redis API Bucket Parser API Website Mobile App
Do one thing, and do it well
... is rule #1
If all you have is a hammer...
... everything looks like a nail
Rule #2
Use the right tool for the job
LNMPNRM
LNMPNRM • Linux
LNMPNRM • Linux • nginx
LNMPNRM • Linux • nginx • MySQL
LNMPNRM • Linux • nginx • MySQL • PHP
LNMPNRM • Linux • nginx • MySQL • PHP •
NodeJS
LNMPNRM • Linux • nginx • MySQL • PHP •
NodeJS • Redis
LNMPNRM • Linux • nginx • MySQL • PHP •
NodeJS • Redis • Mongo DB
LNMPNRMR? • Linux • nginx • MySQL • PHP •
NodeJS • Redis • Mongo DB • Ruby
Rule #3
Stand on the shoulders of giants
Do one thing, and do it well Use the right
tool for the job Stand on the shoulders of giants
Now for the technical stuff...
Service Oriented Architecture
Shared Nothing Architecture
... Except your database
Make it stateless
Make it event driven
API Driven Design
Models talk to the Database
Models talk to the API
API = Data
Website
Mobile App
Raspberry Pi
API = Data
Things I’ve learned
Expose JSON
REST is good
REST is good Except when it’s not
Databases
We use MySQL
We use InnoDB
MySQL 5.6 EXPLAIN ALL THE THINGS!
None
pt-online-schema-change xtrabackup pt-archive pt-query-digest pt-query-advisor pt-show-grants pt-fingerprint
Things I’ve learned
Indexes go from left to right
User (email, first, last, dob) name_index(first, last) email_index(email) user_index(last, dob)
InnoDB uses primary key in indexes
Speed up SELECT Slow down INSERT Indices
One connection means One query
ORM’s are evil
Denormalisation is ok
Backups
mysqldump
InnoDB Hot Backup
Percona Xtrabackup
1,000,001
Recovery
Choose your battles
Servers
Servers (in the cloud?)
Learn to set up a server
Leave it to the professionals
Virtualisation
Get a VPS with Amazon AWS
Get a VPS with Rackspace
Get a VPS with Azure
Get a VPS with $vpsCompany
Leeds Hack
Things I’ve learned
£££
Multiple small beats one large
Dedicated is good too
Host your own database
Documentation
Not just about writing your own
None
You should also write your own
None
Easy Can we still deploy?
Easy Can we still deploy? Harder What if we need
a new server firing up?
Easy Can we still deploy? Harder What if we need
a new server firing up? Even Harder What if $customComponent breaks?
Make yourself dispensable
Always code as if the guy who ends up maintaining
your code will be a violent psychopath who knows where you live - John f. Woods
Things I’ve learned
Smart Defaults
Dependency Management
Just use Composer or rubygems/npm/pip... etc
Things I’ve learned
Lock your dependecies
v 1.4.2
v 1.4.2 Bug Fix
v 1.4.2 Feature release
v 1.4.2 All hell breaks loose
Lock your dependecies
Control your dependecies
None
Control your dependecies
Automation
Predictability
It saves time
Choose one [MRJC]ake
forever stop /home/user/parser/parser.js && APP_ENV=production forever start -a -l ~/parser-logs/
parser.log -o ~/parser-logs/out.log -e ~/parser-logs/ parser.err.log --minUptime 10000 --spinSleepTime 8000 ~/ parser/parser.js
forever stop /home/user/parser/parser.js && APP_ENV=production forever start -a -l ~/parser-logs/
parser.log -o ~/parser-logs/out.log -e ~/parser-logs/ parser.err.log --minUptime 10000 --spinSleepTime 8000 ~/ parser/parser.js parser_control restart
Automating scary things
Push data not pull
Things I’ve learned
Vagrant
Puppet/Chef
Devops!
Logging
Log *everything*
Aggregated logs
Monolog
Make it an option
Things I’ve learned
Nothing... yet
Outsourcing
Things like hosting repos
Things like sending emails
Things like *insert task*
Outsourcing validation
Things I’ve learned
You don’t have to do everything
Testing
Testing is for peace of mind
It is not a design process
Integration tests over unit tests
Unit tests are nice too
Things I’ve learned
Test only what you need
Behat + Selenium
Being Human
You’re your own worst enemy
Logging queries to MongoDB
Node.js’ process.nextTick
Something I haven’t even realised
Things I’ve learned
Learn to fail
People make mistakes
Believe in yourself
I’m Michael
I’m @mheap I’m Michael
I hope you enjoyed this talk I’m @mheap I’m Michael