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
Database scaling patterns
Search
Mariusz Gil
April 12, 2013
Programming
2
510
Database scaling patterns
Mariusz Gil
April 12, 2013
Tweet
Share
More Decks by Mariusz Gil
See All by Mariusz Gil
Aspect Oriented Programming
mariuszgil
1
280
Designing and implementing GraphQL API
mariuszgil
1
39
Discovering unknown with EventStorming ConFoo
mariuszgil
0
240
Game of Developer Life... Deconstructed
mariuszgil
1
150
Back to forgotten roots
mariuszgil
1
350
Go micro with microservices
mariuszgil
5
520
Machine Learning for the rescue
mariuszgil
0
340
Discovering graph structures
mariuszgil
3
510
Introduction to Aerospike with PHP
mariuszgil
8
710
Other Decks in Programming
See All in Programming
ピグパーティにおけるMongoDB CommunityバージョンからAtlasへの移行事例
10969hotaka
0
130
日付と正規化
megmogmog1965
0
140
DynamoDB コスト最適化っぽいことの基本 with Terraform
kuro_kurorrr
2
250
CSC307 Lecture 13
javiergs
PRO
0
150
なぜ宣言的 UI は壊れにくいのか / Why declarative UI is less fragile
uenitty
29
13k
はしめてのプログラミングとロボット制御
watawatavoltage
0
290
CSC307 Lecture 05
javiergs
PRO
0
210
CSC307 Lecture 11
javiergs
PRO
0
240
Advanced App Shrinking Techniques
cbeyls
2
150
CSC307 Lecture 09
javiergs
PRO
1
500
最近追加した型の紹介とその振り返り
aki19035vc
0
180
3 Effective Rules for Success with Signals in Angular
manfredsteyer
PRO
0
120
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
506
110k
Scaling GitHub
holman
458
140k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
149
45k
RailsConf 2023
tenderlove
16
720
The Pragmatic Product Professional
lauravandoore
29
6.1k
Making the Leap to Tech Lead
cromwellryan
127
8.7k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
52k
Designing the Hi-DPI Web
ddemaree
276
34k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
17
8.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
353
29k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
502
140k
Art, The Web, and Tiny UX
lynnandtonic
291
20k
Transcript
Database scaling patterns Mariusz Gil the we a way
ABOUT ME
EXPERIENCE from 1 to 100+ DB servers
EXPERIENCE from 1 to 100+ DB servers
What i it a ABOUT ?
DATABASE IS MAIN PROBLEM IN 99% OF WEB APPS
TYPICAL ISSUES? NORMALIZED TO xNF INEFFICIENT SCHEMA, BAD INDEXES AND
QUERIES, UNUSED SLOW-LOG
shared setup
!" # $ %% & ' !( !" # !" # shared server
cache all the things, wisely...
!" # $ %% & ' !( !" # !" # shared server
separated servers
!" # $ %% & ' !( !" # !" # DB server
scale up
scale up
denormalization
DB server
!" # $ %% & ' !( !" # !" # !" # $ %% & ' !( !" # !" # DB server
DB server
!" # $ %% & ' !( !" # !" # DB server !" # $ %% & ' !( !" # ) !" # )
DB server DB server
!" # $ %% & ' !( !" # ) !" # ) # $ %% & ' !( !" # !" # ID SENDER_ID RECEIVER_ID ... 1 10 1 2 20 2 3 10 1 4 20 3 5 10 1 6 20 4 7 10 1 USER_ID MESSAGE_ID 1 1 1 3 1 5 1 7 2 2 3 4 4 6 USER_ID MESSAGE_ID 10 1 10 3 10 5 10 7 20 2 20 4 20 6
replication
MASTER-SLAVE scale reads, but not writes
DB master
!" # $ %% & ' !( !" # ) !" # ) DB slave !" # $ %% & ' !( !" # ) !" # ) DB slave !" # $ %% & ' !( !" # ) !" # ) ... INSERT... UPDATE... DELETE... SELECT... SELECT...
MASTER-MASTER just for HA, not for scaling
DB master
!" # $ %% & ' !( !" # ) !" # ) DB master !" # $ %% & ' !( !" # ) !" # ) INSERT... UPDATE... DELETE... SELECT...
sharding
DB shard $ %% &
' !( !" # ) !" # ) DB shard !" # $ %% & ' !( !" # ) !" # ) DB shard !" # $ %% & ' !( !" # ) !" # ) INSERT... UPDATE... DELETE... SELECT... INSERT... UPDATE... DELETE... SELECT... INSERT... UPDATE... DELETE... SELECT...
Sharding i HARD !
Resharding i HARDER !
JOINS FORGET ABOUT IT data could be splitted into many
shards
ALTERS THINK TWICE ABOUT IT altering many shards could be
a nice challenge
fault tolerant multi-master sharding
SCALE WHEN NECESSARY NOT FOR FUN
Alternative TOOLS ?
None
None
None
None
None
Thanks! Any questions? @mariuszgil
[email protected]