In this session we will cover wide area replica sets and using tags for backup. Attendees should be well versed in basic replication and familiar with concepts in the morning's basic replication talk. No beginner topics will be covered in this session
7. Implementation details
• Heartbeat every 2 seconds
– Times out in 10 seconds
• Local DB (not replicated)
– system.replset
– oplog.rs
• Capped collection
• Idempotent version of operation stored
13. Maintenance and Upgrade
• No downtime
• Rolling upgrade/maintenance
– Start with Secondary
– Primary last
– Commands:
• rs.stepDown(<secs>)
• db.version()
• db.serverBuildInfo()
15. Replica Set – 1 Data Center
• Single datacenter
• Single switch & power
• Points of failure:
– Power
– Network
– Data center
– Two node failure
• Automatic recovery of
single node crash
16. Replica Set – 2 Data Centers
• Multi data center
• DR node for safety
• Can’t do multi data
center durable write
safely since only 1
node in distant DC
17. Replica Set – 2 Data Centers
• Analytics
• Disaster Recovery
• Batch Jobs
• Options
– low or zero priority
– hidden
– slaveDelay
18. Replica Set – 3 Data Centers
• Three data centers
• Can survive full data
center loss
• Can do w= { dc : 2 } to
guarantee write in 2
data centers (with tags)
19. Replica Set – 3+ Data Centers
Secondary
Primary
Secondary
Secondary
Secondary delayed
Secondary
Secondary
27. Datacenter awareness (Tagging)
• Control where data is written to, and read from
• Each member can have one or more tags
– tags: {dc: "ny"}
– tags: {dc: "ny", subnet: "192.168", rack:
"row3rk7"}
• Replica set defines rules for write concerns
• Rules can change without changing app code
31. Read Preference Modes
• 5 modes (new in 2.2)
– primary (only) - Default
– primaryPreferred
– secondary
– secondaryPreferred
– Nearest
When more than one node is possible, closest node is used
for reads (all modes but primary)
32. Tagged Read Preference
• Custom read preferences
• Control where you read from by (node) tags
– E.g. { "disk": "ssd", "use": "reporting" }
• Use in conjunction with standard read
preferences
– Except primary
37. Best practices and tips
• Odd number of set members
• Read from the primary except for
– Geographically distribution
– Analytics (separate workload)
• Use logical names not IP Addresses in configs
• Set WriteConcern appropriately for what you are
doing
• Monitor secondaries for lag (Alerts in MMS)
PrimaryData memberSecondaryHot standbyArbitersVoting member
Remind the audience, that there are more options, multi dc failure etc. but this is for single machine failurePriorityFloating point number between 0..100Highest member that is up to date wins Up to date == within 10 seconds of primaryIf a higher priority member catches up, it will force election and win Slave DelayLags behind master by configurable time delay Automatically hidden from clientsProtects against operator errorsFat fingeringApplication corrupts data
Schemaoplog, design considerations of MongoDB.. Not only master slave.Tunable: based on your needs.
Upgrade/maintenanceCommon deployment scenarios
TODO: How people really using it? …Get Data from secodaries (chaining)A good question to ask the audience : 'Why wouldn't you set w={dc:3}'… Why would you ever do that? What would be the complications?
ConsistencyWrite preferencesRead preferences
Using 'someDCs' so that in the event of an outage, at least a majority of the DCs would receive the change. This favors availability over durability.
Using 'allDCs' because we want to make certain all DCs have this piece of data. If any of the DCs are down, this would timeout. This favors durability over availability.
Using 'someDCs' so that in the event of an outage, at least a majority of the DCs would receive the change. This favors availability over durability.