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
How to scale large database
Search
duongkai
May 23, 2013
Programming
3
190
How to scale large database
Bài nói về các kĩ thuật để mở rộng một database lớn.
duongkai
May 23, 2013
Tweet
Share
More Decks by duongkai
See All by duongkai
Common crypto flaws in finance mobile apps
duongkai
0
73
Tetcon-2015 Using TLS correctly
duongkai
2
350
How to use SSL/TLS correctly
duongkai
1
170
5S - Xây dựng và thực hiện
duongkai
0
150
Why Random Matters
duongkai
0
68
Crypto-101 @hackerspace 26/07/2013
duongkai
1
94
Trao đổi email
duongkai
0
150
+TetCon.2013_Hacking.Oracle.2012.pdf
duongkai
0
120
Other Decks in Programming
See All in Programming
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
3
710
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.3k
CSC509 Lecture 12
javiergs
PRO
0
160
Contemporary Test Cases
maaretp
0
140
Functional Event Sourcing using Sekiban
tomohisa
0
110
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
360
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
3
1.2k
EMになってからチームの成果を最大化するために取り組んだこと/ Maximize team performance as EM
nashiusagi
0
100
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
340
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
210
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
260
React への依存を最小にするフロントエンド設計
takonda
12
3.7k
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
32
1.5k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Making Projects Easy
brettharned
115
5.9k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Bash Introduction
62gerente
608
210k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Transcript
How To Scale Large Database Phạm Tùng Dương – CIO03
Course: Advanced Database
Overview • First glance about Large Database • Typical techniques
to scale • Database sharding • Database sharding in MySQL
First glance about Large Database
When You Talk about Large Database
Example Tumblr @2012
Example • 400 million active users • 5 billion pieces
of content per week • 3 billion photos uploaded per month Facebook@2010
Example • 1 billion tweets per week • 140 million
tweets sent per day • 456 tweets per second @MJ death • 6939 tweets per second on NY day Twitter@2011
What is The Large Database • Large working data sets
• I/O write intensive
Typical approaches
What is The Bottleneck? I/O, I/O and I/O
We have a job which is called Performance Tuning
Scale up • Adding more RAM, more CPU • High
I/O HDD
Scale topo Replication (Master – Slave) Master Slave Client Read/Write
Read Only Master Master Storage Client Cluster (shared storage)
Caching • Memcached • Redis
Finally, Everything in RAM is a Dream!
But, No Silver Bullet!
Database Sharding
What is Database Sharding • Horizontal Partitioning • Data is
stored in small chunks and distributed across many computers • Often use with Replication
Database sharding topo Primary DB Shard1 Shard2
Shard3 Slave1 Slave2 Slave3
3 types • Range sharding • List sharding (Lookup table)
• Hash sharding
Range sharding • Distributed by the range of Primary Key
• Example – Primary Key: user_id (1..1000) user_shard1 (1..500) user_shard2 (501..1000)
List sharding • Distributed data by the attribute of the
data • Example: database of people in VN – Sharded by the city_name (Ha_Noi, Hai_Phong, Da_Nang,…)
Hash sharding (modulus) • Distributed data by using a hash
function on primary key. • Example: primary_key mod N
Pros of Database Sharding • Easy to scale (data, write
I/O) • Using commodity hardware • Minimum effect when system failed
Cons of Database sharding • You MUST implement by yourselves
• Operation is harder • Handle join operation is very difficult • Data denormalization – > Don’t do it because it’s COOL!
Database Sharding in MySQL
Sharding Solutions • Application layer • Storage layer • Heavy
middleware • Lightweight middleware
Application layer • Hibernate Shards • HiveDB
Storage layer • MySQL Spider – Requires to change storage engine
of MySQL
Heavy Middleware • Twitter Gizzard • dbShards – Each db
has an agent
Lightweight Middleware • Acts like a proxy • Route the
request • Spock, CUBRID
You Will Do It Because You Have To … not
because it’s Cool!
Q&A