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
Michael Heap
October 06, 2012
Technology
1
1.4k
Designing systems to scale
Talk given at PHPNW12 in Manchester, England
Michael Heap
October 06, 2012
Tweet
Share
More Decks by Michael Heap
See All by Michael Heap
WTF are OKRs?
mheap
0
360
But why does the business care?
mheap
0
220
Advanced GitHub Actions
mheap
0
480
Controlling Your Kong Gateway With decK and CI/CD
mheap
0
430
API Standards 2.0
mheap
1
1.1k
API Standards 2.0
mheap
0
540
Dr Sheldon Cooper Presents: Fun with Flags (NEPHP)
mheap
0
600
Dr Sheldon Cooper Presents: Fun with Flags
mheap
0
990
Behat for characterization tests
mheap
0
440
Other Decks in Technology
See All in Technology
我々は雰囲気で仕事をしている / How can we do vibe coding as well
naospon
2
220
実践アプリケーション設計 ①データモデルとドメインモデル
recruitengineers
PRO
4
850
夢の印税生活 / Life on Royalties
tmtms
0
290
VPC Latticeのサービスエンドポイント機能を使用した複数VPCアクセス
duelist2020jp
0
320
攻撃と防御で実践するプロダクトセキュリティ演習~導入パート~
recruitengineers
PRO
3
940
KiroでGameDay開催してみよう(準備編)
yuuuuuuu168
1
150
Yahoo!ニュースにおけるソフトウェア開発
lycorptech_jp
PRO
0
450
AIとTDDによるNext.js「隙間ツール」開発の実践
makotot
6
750
【Oracle Cloud ウェビナー】[最新動向]:AIエージェント大量生産時代に突入、AI-Readyなデータプラットフォームのススメ
oracle4engineer
PRO
3
110
そのコンポーネント、サーバー?クライアント?App Router開発のモヤモヤを可視化する補助輪
makotot
4
730
Go で言うところのアレは TypeScript で言うとコレ / Kyoto.なんか #7
susisu
7
2k
RAID6 を楔形文字で組んで現代人を怖がらせましょう(実装編)
mimifuwa
1
320
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
36
6.8k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Making the Leap to Tech Lead
cromwellryan
134
9.5k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.5k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
480
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Music & Morning Musume
bryan
46
6.8k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
30
9.6k
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