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
27
State of Open Con '24
vpetersson
0
52
From Pets to Cattle
vpetersson
0
120
Beyond Just a Menu Display
vpetersson
0
65
The history of how Screenly OSE became the most popular digital signage project on GitHub
vpetersson
0
140
The DevSecOps Iceberg @ Cloud Native London
vpetersson
0
360
What's mtLS? @ Docker London
vpetersson
0
480
The "S" in "IoT" stands for "Security"
vpetersson
0
210
Living on the Edge @ Kubernetes London
vpetersson
0
110
Other Decks in Technology
See All in Technology
B2B SaaS × AI機能開発 〜テナント分離のパターン解説〜 / B2B SaaS x AI function development - Explanation of tenant separation pattern
oztick139
2
220
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
570
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
120
SSMRunbook作成の勘所_20241120
koichiotomo
1
110
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
Amazon Personalizeのレコメンドシステム構築、実際何するの?〜大体10分で具体的なイメージをつかむ〜
kniino
1
100
TypeScript、上達の瞬間
sadnessojisan
46
13k
地理情報データをデータベースに格納しよう~ GPUを活用した爆速データベース PG-Stromの紹介 ~
sakaik
1
150
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
370
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.8k
【令和最新版】AWS Direct Connectと愉快なGWたちのおさらい
minorun365
PRO
5
750
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
For a Future-Friendly Web
brad_frost
175
9.4k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Fireside Chat
paigeccino
34
3k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Bash Introduction
62gerente
608
210k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
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