-
Notifications
You must be signed in to change notification settings - Fork 0
MongoDB Atlas Global Clusters Try
John Zheng edited this page Jan 6, 2021
·
8 revisions
MongoDB enable Global Cluster from 2018, and support 18 regions in AWS now.
- It support write-write for different regions, and sync data with low latency.
- It support data residency for regulatory requirements (like GRPC).
I would like to try and see whether it real works.
I create a cluster in 3 regions: Virginia/Frankfurt/Singapore
clusterworldwide-shard-0 -- Zone 1 -- 3 Nodes in Virginia,US
clusterworldwide-shard-00-00-1pqkb.mongodb.net:27017 <Primary>
clusterworldwide-shard-00-01-1pqkb.mongodb.net:27017
clusterworldwide-shard-00-02-1pqkb.mongodb.net:27017
clusterworldwide-shard-1 -- Zone 2 -- 3 Nodes in Frankfurt, German
clusterworldwide-shard-01-01-1pqkb.mongodb.net:27017 <Primary>
clusterworldwide-shard-01-01-1pqkb.mongodb.net:27017
clusterworldwide-shard-01-02-1pqkb.mongodb.net:27017
clusterworldwide-shard-2 -- Zone 3 -- 3 Nodes in Singapore
clusterworldwide-shard-02-00-1pqkb.mongodb.net:27017 <Primary>
clusterworldwide-shard-02-01-1pqkb.mongodb.net:27017
clusterworldwide-shard-02-02-1pqkb.mongodb.net:27017
I connect three different cluster (region) with three different console:
Connect to US Shard, insert a document.
ubuntu@ip-10-200-224-19:~$ mongo "mongodb://clusterworldwide-shard-00-00-1pqkb.mongodb.net:27016/test" --ssl --authenticationDatabase admin --username dev-test --password
MongoDB Enterprise mongos> use test;
switched to db test
MongoDB Enterprise mongos> db.try1.insert({"k1":"v1"})
WriteResult({ "nInserted" : 1 })
Connect to German Shard, can query this document out
ubuntu@ip-10-200-224-19:~$ mongo "mongodb://clusterworldwide-shard-01-00-1pqkb.mongodb.net:27016/test" --ssl --authenticationDatabase admin --username dev-test --password
MongoDB Enterprise mongos> use test;
switched to db test
MongoDB Enterprise mongos> db.try1.find()
{ "_id" : ObjectId("5e032d2e3892bae579e0056c"), "k1" : "v1" }
Connect to Singapore shard, can query this document out
ubuntu@ip-10-200-224-19:~$ mongo "mongodb://clusterworldwide-shard-02-00-1pqkb.mongodb.net:27016/test" --ssl --authenticationDatabase admin --username dev-test --password
MongoDB Enterprise mongos> use test;
switched to db test
MongoDB Enterprise mongos> db.try1.find()
{ "_id" : ObjectId("5e032d2e3892bae579e0056c"), "k1" : "v1" }
I test more, no matter which console I insert, it can be queryed out in other shard(console) very sooner.
I create another collection "try2", then enable "Global Writes" for "try2".
Per design,
- If I create document with {"location":"US"}, the data should be saved in US shard only.
- If I create document with {"location":"GE"}, the data should be saved in German shard only.
- If I create document with {"location":"SG"}, the data should be saved in Singapore shard only.
- If I create document with location like GB (England), it will find the nearest shard (German), the data should be saved in German shard only.
MongoDB Enterprise mongos> db.try2.insert({"location" : "DE", "pid" : "000001", "k1":"v1"})
WriteResult({ "nInserted" : 1 })
MongoDB Enterprise mongos> db.try2.insert({"location" : "GK", "pid" : "000001", "k1":"v1"})
WriteResult({ "nInserted" : 1 })
MongoDB Enterprise mongos> db.try2.getShardDistribution()
Shard clusterworldwide-shard-2 at clusterworldwide-shard-2/clusterworldwide-shard-02-00-1pqkb.mongodb.net:27017,clusterworldwide-shard-02-01-1pqkb.mongodb.net:27017,clusterworldwide-shard-02-02-1pqkb.mongodb.net:27017
data : 0B docs : 0 chunks : 236 #Singapore
Shard clusterworldwide-shard-1 at clusterworldwide-shard-1/clusterworldwide-shard-01-00-1pqkb.mongodb.net:27017,clusterworldwide-shard-01-01-1pqkb.mongodb.net:27017,clusterworldwide-shard-01-02-1pqkb.mongodb.net:27017
data : 132B **docs : 2** chunks : 258 #German
Shard clusterworldwide-shard-0 at clusterworldwide-shard-0/clusterworldwide-shard-00-00-1pqkb.mongodb.net:27017,clusterworldwide-shard-00-01-1pqkb.mongodb.net:27017,clusterworldwide-shard-00-02-1pqkb.mongodb.net:27017
data : 0B docs : 0 chunks : 151 #US
Totals
data : 132B docs : 2 chunks : 645
MongoDB Enterprise mongos> db.try2.insert({"location" : "SG", "pid" : "000003", "k3":"v3"})
WriteResult({ "nInserted" : 1 })
MongoDB Enterprise mongos> db.try2.getShardDistribution()
Shard clusterworldwide-shard-1 at clusterworldwide-shard-1/clusterworldwide-shard-01-00-1pqkb.mongodb.net:27017,clusterworldwide-shard-01-01-1pqkb.mongodb.net:27017,clusterworldwide-shard-01-02-1pqkb.mongodb.net:27017
data : 132B docs : 2 chunks : 258 #German
Shard clusterworldwide-shard-0 at clusterworldwide-shard-0/clusterworldwide-shard-00-00-1pqkb.mongodb.net:27017,clusterworldwide-shard-00-01-1pqkb.mongodb.net:27017,clusterworldwide-shard-00-02-1pqkb.mongodb.net:27017
data : 0B docs : 0 chunks : 151 #US
Shard clusterworldwide-shard-2 at clusterworldwide-shard-2/clusterworldwide-shard-02-00-1pqkb.mongodb.net:27017,clusterworldwide-shard-02-01-1pqkb.mongodb.net:27017,clusterworldwide-shard-02-02-1pqkb.mongodb.net:27017
data : 66B docs : 1 chunks : 236 #Singpore
Totals
data : 198B docs : 3 chunks : 645
Please feel free to correct me if I am wrong, thanks.
AWS aurora(SQL DB) and dynamicdb (NoSQL DB) also support global clusters well now.