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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
duongkai
May 23, 2013
Programming
3
200
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
84
Tetcon-2015 Using TLS correctly
duongkai
2
370
How to use SSL/TLS correctly
duongkai
1
180
5S - Xây dựng và thực hiện
duongkai
0
160
Why Random Matters
duongkai
0
77
Crypto-101 @hackerspace 26/07/2013
duongkai
1
110
Trao đổi email
duongkai
0
160
+TetCon.2013_Hacking.Oracle.2012.pdf
duongkai
0
160
Other Decks in Programming
See All in Programming
AI活用のコスパを最大化する方法
ochtum
0
250
Kubernetesでセルフホストが簡単なNewSQLを求めて / Seeking a NewSQL Database That's Simple to Self-Host on Kubernetes
nnaka2992
0
160
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
240
安いハードウェアでVulkan
fadis
0
570
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
120
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
2.5k
Understanding Apache Lucene - More than just full-text search
spinscale
0
130
Ruby and LLM Ecosystem 2nd
koic
1
1.1k
AI Assistants for Your Angular Solutions
manfredsteyer
PRO
0
150
技術検証結果の整理と解析をAIに任せよう!
keisukeikeda
0
130
AWS Infrastructure as Code の新機能 2025 総まとめ 〜SA 4人による怒涛のデモ祭り〜
konokenj
10
3.4k
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
1.1k
Featured
See All Featured
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.9k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
830
How to Talk to Developers About Accessibility
jct
2
160
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
200
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
WENDY [Excerpt]
tessaabrams
9
36k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
980
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Side Projects
sachag
455
43k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
140
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