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
MongoDB's Replica Sets - Painless scaling and ...
Search
Viktor Petersson
August 30, 2012
Technology
3
2.6k
MongoDB's Replica Sets - Painless scaling and High Availability (HA)
Presentation for NoSQL Roadshow (Basel, Switzerland).
Viktor Petersson
August 30, 2012
Tweet
Share
More Decks by Viktor Petersson
See All by Viktor Petersson
Navigating the SBOM landscape: Formats, relevance, and tooling in 2024 @ BSides Bristol '24
vpetersson
0
110
State of Open Con '24
vpetersson
0
110
From Pets to Cattle
vpetersson
0
190
Beyond Just a Menu Display
vpetersson
0
110
The history of how Screenly OSE became the most popular digital signage project on GitHub
vpetersson
0
210
The DevSecOps Iceberg @ Cloud Native London
vpetersson
0
440
What's mtLS? @ Docker London
vpetersson
0
570
The "S" in "IoT" stands for "Security"
vpetersson
0
280
Living on the Edge @ Kubernetes London
vpetersson
0
150
Other Decks in Technology
See All in Technology
やる気のない自分との向き合い方/How to Deal with Your Unmotivated Self
sanogemaru
0
440
Goに育てられ開発者向けセキュリティ事業を立ち上げた僕が今向き合う、AI × セキュリティの最前線 / Go Conference 2025
flatt_security
0
370
The Cake Is a Lie... And So Is Your Login’s Accessibility
leichteckig
0
100
AIツールでどこまでデザインを忠実に実装できるのか
oikon48
6
3k
Geospatialの世界最前線を探る [2025年版]
dayjournal
0
170
AIAgentの限界を超え、 現場を動かすWorkflowAgentの設計と実践
miyatakoji
1
160
小学4年生夏休みの自由研究「ぼくと Copilot エージェント」
taichinakamura
0
550
Vibe Coding Year in Review. From Karpathy to Real-World Agents by Niels Rolland, CEO Paatch
vcoisne
0
110
SoccerNet GSRの紹介と技術応用:選手視点映像を提供するサッカー作戦盤ツール
mixi_engineers
PRO
1
190
From Prompt to Product @ How to Web 2025, Bucharest, Romania
janwerner
0
120
生成AIで「お客様の声」を ストーリーに変える 新潮流「Generative ETL」
ishikawa_satoru
1
360
Optuna DashboardにおけるPLaMo2連携機能の紹介 / PFN LLM セミナー
pfn
PRO
2
930
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
2.7k
Speed Design
sergeychernyshev
32
1.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
30
2.9k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.7k
The Power of CSS Pseudo Elements
geoffreycrofte
79
6k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.1k
How to Ace a Technical Interview
jacobian
280
24k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.7k
How to Think Like a Performance Engineer
csswizardry
27
2k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Bash Introduction
62gerente
615
210k
Transcript
Replica Sets Painless scaling and High Availability (HA) Viktor Petersson
@vpetersson
Who am I? { name : ‘Viktor Petersson’, description :
[ ‘geek’, ‘entrepreneur’ ], founder_of : ‘wireload’, twitter : ‘@vpetersson’, email : ‘
[email protected]
’, } @vpetersson
What is MongoDB? @vpetersson • Key-value store • Schemas less
• Distributed file system (GridFS) • Built-in Map/Reduce • Built to scale
MongoDB 101 Relational Database MongoDB Database Database Table Collection Row
Document Database structure (simplified) @vpetersson
MongoDB 101 Relational Database MongoDB Master Primary Slave Secondary Arbiter
(Hidden) Node types @vpetersson
What are Replica Sets and why should I care? @vpetersson
Typical failover with relational databases Master Slave Failover IP Master
Slave Failover IP Master Normal Degraded @vpetersson (two servers, can lose one)
More complex failover with relational databases Failover IP Normal @vpetersson
Proxies Database servers Failover IP Degraded (four servers, can lose one of each kind)
Failover with MongoDB Primary Secondary Normal Degraded Secondary Driver Primary
Secondary Secondary Driver Primary @vpetersson (three servers, can lose two)
Primary Secondary Down -> Recovering Recovering -> Secondary Secondary Driver
Primary Secondary Secondary Driver Primary Secondary Primary Recovering Automatic recovery @vpetersson
Real life example: Taking down the primary for maintenance. No
dropped connections. Primary Secondary @vpetersson
Creating a Replica Set is dead simple. All it takes
is three servers (s0, s1, s2) and three commands¹. $ mongo > rs.initiate() > rs.add(‘s1’) > rs.add(‘s2’) 1. After adding “replSet=myRepSet” and “rest = true” to mongo.conf @vpetersson
Live demo! 3 servers with 1 client @vpetersson
Election @vpetersson 1. Most up to date 2. Highest priority
3. Less than 10s behind Primary
Configure node priority $ cfg = rs.conf() $ cfg.members[x].priority =
n $ rs.reconfig(cfg) x = Member id, n = Priority (0 - 100), default is 1. @vpetersson
Leverage your secondary-nodes Warning: Secondaries may be out-of-date. Read preference
• Primary (default) • Secondary • Secondary_only @vpetersson
What happens when I’ve outgrown my Replica Set? @vpetersson
@vpetersson mongos repset0 repset1 repsetN Sharding
Useful commands View server status $ db.serverStatus() View the replication
status $ rs.status() Step down as Primary $ rs.stepDown(n) @vpetersson
• Improved location awareness • Improved concurrent capacity • TTL
collections @vpetersson What’s new in MongoDB 2.2? Full release notes: http://docs.mongodb.org/manual/release-notes/2.2/ (released yesterday)
Summary @vpetersson • Replica Sets are extremely easy to set
up • Doesn’t require failover IPs or custom scripts • Minimal maintenance • Built to scale
Questions? @vpetersson
Thanks to @vpetersson
Contact me! email:
[email protected]
www: viktorpetersson.com twitter: @vpetersson Also visit
WireLoad.net YippieMove.com @vpetersson This deck will be available at ViktorPetersson.com.
• MongoDB: GridFS, sharding and deploying in the cloud (http://goo.gl/1QAV1)
• MongoDB Replica Set (http://goo.gl/D2pkq) • 10gen (http://goo.gl/3m4Kn) @vpetersson Useful resources