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
Scaling MongoDB | Sergey Gavruk
Search
Minsk MongoDB User Group
October 04, 2012
Programming
190
2
Share
Scaling MongoDB | Sergey Gavruk
Sergey Gavruk
Meetup #7
Minsk MongoDB User Group
October 04, 2012
More Decks by Minsk MongoDB User Group
See All by Minsk MongoDB User Group
MongoDB by Chef | Yauhen Artsiukhou
bymongo
0
140
MongoDB at IronMQ | Alexander Kolesen
bymongo
0
860
Event sourcing + CQRS + MongoDB | Alex Shkor
bymongo
1
650
How it works. Indexes | Kirill Duborenko
bymongo
5
290
Aggregation Framework | Mikhail Burtylev
bymongo
1
120
MongoDB 2.2: Release update + Roadmap | Alvin Richards
bymongo
1
110
Meetup#6 Intro | Alex Litvinok
bymongo
1
62
Deploying MongoDB on Amazon WS | Michael Karpitsky
bymongo
2
130
About the problem of DBMS choice & what to do if you have gone the wrong way | Roman Bugaev
bymongo
3
130
Other Decks in Programming
See All in Programming
CDK Deployのための ”反響定位”
watany
4
740
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
120
「速くなった気がする」をデータで疑う
senleaf24
0
170
セグメントとターゲットを意識するプロポーザルの書き方 〜採択の鍵は、誰に刺すかを見極めるマーケティング戦略にある〜
m3m0r7
PRO
0
510
t *testing.T は どこからやってくるの?
otakakot
0
480
10 Tips of AWS ~Gen AI on AWS~
licux
5
360
PCOVから学ぶコードカバレッジ #phpcon_odawara
o0h
PRO
0
260
Xdebug と IDE による デバッグ実行の仕組みを見る / Exploring-How-Debugging-Works-with-Xdebug-and-an-IDE
shin1x1
0
370
Rethinking API Platform Filters
vinceamstoutz
0
11k
iOS機能開発のAI環境と起きた変化
ryunakayama
0
180
PDI: Como Alavancar Sua Carreira e Seu Negócio
marcelgsantos
0
120
今年もTECHSCOREブログを書き続けます!
hiraoku101
0
250
Featured
See All Featured
Designing for Timeless Needs
cassininazir
0
190
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
240
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.5k
For a Future-Friendly Web
brad_frost
183
10k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Code Review Best Practice
trishagee
74
20k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.6k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Transcript
Scaling Sergey Gavruk @gavruk
Scaling • Ver2cal • Horizontal • By op2miza2on – Op2mize
your queries, schema, indexes – Tune you file system – Choose right disks
Share nothing architecture • Michael Stonebraker First
implementa2on in 1983 Google calls this “Sharding”
Sharding goals • App doesn’t know about clusters • Cluster
should always be available for reads and writes • Cluster should grow easily
Sharding features • Range-‐based data par22oning • Automa2c
data volume distribu2on • Transparent query rou2ng
[“a”, “g”) [“g”, “m”) [“m”, “s”) [“s”,
“z”)
[“a”, “g”) [“g”, “m”) [“m”, “s”) [“s”,
“z”) [“d”, “g”) 100 GB 500 GB 100 GB 100 GB 100 GB 400 GB 200 GB 100 GB
[“a”, “g”) [“g”, “m”) [“m”, “s”) [“s”,
“z”)
[“a”, “d”) 300 [“g”, “k”) 300 [“m”,
“s”) [“s”, “z”) 400 GB 400 GB 100 GB 100 GB [“d”, “g”) 100 [“k”, “m”) 100
None
Chunks -‐∞ +∞
Chunks -‐∞ +∞
null Numbers Strings Objects Arrays
binary data ObjectIds booleans Dates regular expressions smaller bigger
Balancing mongos balancer Config server Config
server Config server Shard 1 Shard 2
Balancer goals • keep data distributed • minimize the amount
of data transfered
Balancing mongos balancer Config server Config
server Config server Shard 1 Shard 2 Move chunk X to shard 2
Balancing Number of chunks Migra:on threshold <
20 2 21-‐80 4 80+ 8
Balancing schedule db.seangs.update({ _id : "balancer" },
{ $set : { ac2veWindow : { start : "23:00", stop : "6:00" } } }, true )
Routed Request mongos Shard 1 Shard 2
Shard 3
mongos Shard 1 Shard 2 Shard 3
Request without shard key
Without shard key + sor2ng mongos Shard 1
Shard 2 Shard 3
Consider the shard cluster if: • Data exceeds the
storage capacity of a single node • Size of working set will soon exceed your RAM • Large amount of writes
Restric2ons • You cannot update a shard key
• You must use a shard key for a single update • Index on shard key
Ideal shard key • easily divisible. • will
distribute write opera2ons among the cluster • will make it possible for the mongos to return most query opera2ons directly from a single specific mongod instance
Choosing a shard key {
_id: "1", user_id: "2345652221", date_2me: "2012-‐10-‐04“, tweet_text: “Hello world” } Reliability
Choosing a shard key Ascending { TimeStamp:
12355232, … }
Choosing a shard key Low-‐cardinality key {
Con:nent: “Europe”, Name: “Tom”, … } Zip code?
Demo
Any questions? mailto:
[email protected]