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
120
State of Open Con '24
vpetersson
0
120
From Pets to Cattle
vpetersson
0
190
Beyond Just a Menu Display
vpetersson
0
120
The history of how Screenly OSE became the most popular digital signage project on GitHub
vpetersson
0
220
The DevSecOps Iceberg @ Cloud Native London
vpetersson
0
450
What's mtLS? @ Docker London
vpetersson
0
610
The "S" in "IoT" stands for "Security"
vpetersson
0
300
Living on the Edge @ Kubernetes London
vpetersson
0
150
Other Decks in Technology
See All in Technology
Agent Skillsがハーネスの垣根を超える日
gotalab555
6
4.5k
AWS re:Invent 2025~初参加の成果と学び~
kubomasataka
1
200
AgentCore BrowserとClaude Codeスキルを活用した 『初手AI』を実現する業務自動化AIエージェント基盤
ruzia
7
1.7k
オープンソースKeycloakのMCP認可サーバの仕様の対応状況 / 20251219 OpenID BizDay #18 LT Keycloak
oidfj
0
200
AWSインフルエンサーへの道 / load of AWS Influencer
whisaiyo
0
230
Oracle Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
3
200
通勤手当申請チェックエージェント開発のリアル
whisaiyo
3
490
アラフォーおじさん、はじめてre:Inventに行く / A 40-Something Guy’s First re:Invent Adventure
kaminashi
0
170
ソフトウェアエンジニアとAIエンジニアの役割分担についてのある事例
kworkdev
PRO
0
300
モダンデータスタックの理想と現実の間で~1.3億人Vポイントデータ基盤の現在地とこれから~
taromatsui_cccmkhd
2
270
NIKKEI Tech Talk #41: セキュア・バイ・デザインからクラウド管理を考える
sekido
PRO
0
230
業務の煩悩を祓うAI活用術108選 / AI 108 Usages
smartbank
9
15k
Featured
See All Featured
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
400
sira's awesome portfolio website redesign presentation
elsirapls
0
91
My Coaching Mixtape
mlcsv
0
14
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
200
4 Signs Your Business is Dying
shpigford
187
22k
Un-Boring Meetings
codingconduct
0
170
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.4k
Prompt Engineering for Job Search
mfonobong
0
130
Applied NLP in the Age of Generative AI
inesmontani
PRO
3
2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.9k
Git: the NoSQL Database
bkeepers
PRO
432
66k
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