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
2.7k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
MongoDB's Replica Sets - Painless scaling and High Availability (HA)
Presentation for NoSQL Roadshow (Basel, Switzerland).
Viktor Petersson
August 30, 2012
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
150
State of Open Con '24
vpetersson
0
140
From Pets to Cattle
vpetersson
0
220
Beyond Just a Menu Display
vpetersson
0
150
The history of how Screenly OSE became the most popular digital signage project on GitHub
vpetersson
0
280
The DevSecOps Iceberg @ Cloud Native London
vpetersson
0
490
What's mtLS? @ Docker London
vpetersson
0
670
The "S" in "IoT" stands for "Security"
vpetersson
0
340
Living on the Edge @ Kubernetes London
vpetersson
0
170
Other Decks in Technology
See All in Technology
Alphaモジュール使っていいのかい!?いけないのかい!?どっちなんだいっ!?
watany
1
290
複数プロダクト組織のAIネイティブ化における戦略 / AICon2026_kude
rakus_dev
0
160
データエンジニアリングとドメイン駆動設計
masuda220
PRO
4
210
発表と総括 / Presentations and Summary
ks91
PRO
0
150
マルチアカウント環境でSecurity Hubの運用、その後どうなった? / SRE NEXT 2026 miniLT会
genda
0
110
AI時代の開発生産性を捉え直す — 経営と現場をつなぐ「開発組織のオブザーバビリティ」— / AI Dev Ex Conference 2026
tkyowa
0
190
AI、CDK と協働する Full TypeScript アプリケーション開発 / Full TypeScript Application with AI and CDK
geekplus_tech
2
410
AI時代の闇と光
tatsuya1970
0
110
LLMやAIエージェントをソフトウェアに組み込むプラクティス
shibuiwilliam
2
430
ファミコンでPHPを動かす / PHP on the Famicom
tomzoh
2
490
Amplify Gen2でbackend.tsにCDKを定義する/しない事によるCDKの挙動の違いとユースケース
smt7174
1
440
「AIに依存している」と 「AIを使いこなしている」の違い
k8yasuma
0
120
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
550
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
420
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
650
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
210
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
190
Abbi's Birthday
coloredviolet
3
8.7k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.6k
We Have a Design System, Now What?
morganepeng
55
8.2k
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