This document discusses strategies for using MongoDB in a distributed environment across multiple data centers. It describes setting up MongoDB replica sets in three different locations to allow for local writes and reads while minimizing remote data access. It also covers features like write concern, read preferences, and geo-aware sharding that can be used to control data routing and consistency for scenarios like social networks, analytics, authentication, and administration systems.
2. @spf13
AKA
Steve Francia
15+ years building
the internet
Father, husband,
skateboarder
Chief Solutions Architect @
responsible for drivers,
integrations, web & docs
30. Write Concern
&
If a write requires a
return trip
What the return trip should
depend on
31. Write Concern
w:
the number of servers to replicate to.
wtimeout:
timeout in ms waiting for replication.
j:
wait for journal sync
tags:
ensure replication to certain tagged nodes
32. Write Concern
Mongo mongo = new Mongo(
new MongoURI("mongodb://
127.0.0.1:27017,127.0.0.1:27018"));
mongo.setWriteConcern(
new WriteConcern(2, 1000));
33. Write Concern
Mongo mongo = new Mongo(
new MongoURI("mongodb://
127.0.0.1:27017,127.0.0.1:27018"));
DBCollection users =
mongo.getDB(“myapp”).getCollection(“users”);
users.insert( new DBObject("name", "Kyle"),
new WriteConcern(2, 1000))