Skip to content

Instantly share code, notes, and snippets.

@davefinster
Created October 25, 2016 08:47
Show Gist options
  • Save davefinster/476643400fd669b7761d703d809c58e0 to your computer and use it in GitHub Desktop.
Save davefinster/476643400fd669b7761d703d809c58e0 to your computer and use it in GitHub Desktop.
Assuming that each
+-------+
|Primary|
| 75GB |
+-------+
is a separate server
Single MongoDB Server
If this server dies, all data is unavailable
+-------+
|Primary|
| 75GB |
+-------+
MongoDB with Replica Sets
If the primary dies, the secondary will take over for the entire database
Replica Set
|
|
/ \
+-------+ +---------+
|Primary| |Secondary|
| 75GB |=| 75GB |
+-------+ +---------+
MongoDB with Sharding
If a server dies, then all the data inside the shard that died will become unavailable.
Sharded Cluster
/ | \
Shard A Shard B Shard C
| | |
+-------+ +-------+ +-------+
|Primary| |Primary| |Primary|
| 25GB | | 25 GB | | 25 GB |
+-------+ +-------+ +-------+
MongoDB with Sharding and Replication
If a server dies, then if it was a primary for a shard, then only that shard will move over to its secondary
Sharded Cluster
/ | \
Shard A Shard B Shard C
/ \ / \ / \
+-------+ +---------+ +-------+ +---------+ +-------+ +---------+
|Primary| |Secondary| |Primary| |Secondary| |Primary| |Secondary|
| 25GB |=| 25GB | | 25 GB |=| 25 GB | | 25GB |=| 25GB |
+-------+ +---------+ +-------+ +---------+ +-------+ +---------+
RethinkDB (replica=1, shard=1)
If this server dies, all data is unavailable
+-------+
|Primary|
| 75GB |
+-------+
RethinkDB (replica=1, shard=3)
If a server dies, then all the data inside the shard that died will become unavailable.
RethinkDB Cluster
/ | \
Shard A Shard B Shard C
| | |
+-------+ +-------+ +-------+
|Primary| |Primary| |Primary|
| 25GB | | 25 GB | | 25 GB |
+-------+ +-------+ +-------+
RethinkDB (replica=3, shard=1)
If a server dies, one of the secondaries will become the new primary
RethinkDB Cluster
|
|
/ | \
+-------+ +---------+ +---------+
|Primary| |Secondary| |Secondary|
| 75GB |=| 75GB |=| 75GB |
+-------+ +---------+ +---------+
RethinkDB (replica=3, shard=3)
If a server dies, then the affected shard will elect a new primary replica
RethinkDB Cluster
/ | \
Shard A Shard B Shard C
/ | \ / | \ / | \
+-------+ +---------+ +---------+ +-------+ +---------+ +---------+ +-------+ +---------+ +---------+
|Primary| |Secondary| |Secondary| |Primary| |Secondary| |Secondary| |Primary| |Secondary| |Secondary|
| 25GB |=| 25GB |=| 25GB | | 25GB |=| 25GB |=| 25GB | | 25GB |=| 25GB |=| 25GB |
+-------+ +---------+ +---------+ +-------+ +---------+ +---------+ +-------+ +---------+ +---------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment