SlideShare a Scribd company logo
Open source, high performance database




 Replication

                                 Summer 2012

                                               1
Why Have Replication?


                        2
• High Availability (auto-failover)

• Read Scaling (extra copies to read from)

• Backups
 – Online, Delayed Copy (fat finger)
 – Point in Time (PiT) backups

• Use (hidden) replica for secondary workload
 – Analytics
 – Data-processing
 – Integration with external systems            3
Planned
–   Hardware upgrade
–   O/S or file-system tuning
–   Relocation of data to new file-system / storage
–   Software upgrade


Unplanned
–   Hardware failure
–   Data center failure
–   Region outage
–   Human error
–   Application corruption                            4
• A cluster of N servers
• All writes to primary
• Reads can be to primary (default) or a
  secondary
• Any (one) node can be primary
• Consensus election of primary
• Automatic failover
• Automatic recovery
                                           5
Member 1                  Member 3




                        Member 2




• Replica Set is made up of 2 or more nodes


                                                6
Member 1              Member 3




                    Member 2
                    Primary




• Election establishes the PRIMARY
• Data replication from PRIMARY to SECONDARY

                                               7
negotiate new
                     master
          Member 1                   Member 3




                      Member 2
                      DOWN



• PRIMARY may fail
• Automatic election of new PRIMARY
      if majority exists

                                                8
negotiate new
                     master
                                     Member 3
          Member 1                   Primary




                      Member 2
                      DOWN




• New PRIMARY elected
• Replica Set re-established

                                                9
Member 3
           Member 1
                                    Primary




                       Member 2
                       Recovering




• Automatic recovery



                                               10
Member 3
            Member 1
                                  Primary




                       Member 2




• Replica Set re-established



                                             11
Understanding automatic failover

                               12
Primary    As long as a partition
Secondary
            can see a majority
            (>50%) of the
Secondary   cluster, then it will elect a
            primary.


                                            13
Primary    66% of cluster visible.
Secondary
            Primary is elected

  Failed
   Node




                                      14
Secondary   33% of cluster visible.
  Failed
            Read only mode.
   Node

  Failed
   Node




                                      15
Primary



Secondary




Secondary




            16
Primary
                        66% of cluster visible
            Secondary
                        Primary is elected
 Primary

              Failed
Secondary      Node




Secondary




                                           17
Primary



Secondary
              Failed
               Node

              Failed
               Node
Secondary


            Secondary
                        33% of cluster visible
                        Read only mode.
                                           18
Primary



Secondary




Secondary




Secondary



            19
Secondary
                        50% of cluster visible
 Primary
            Secondary   Read only mode.
              Failed
Secondary      Node

              Failed
               Node


Secondary




Secondary



                                            20
Primary
              Failed
               Node
Secondary
              Failed
               Node


            Secondary

Secondary               50% of cluster visible
            Secondary   Read only mode.
Secondary



                                            21
Avoid single points of failure

                            22
23
Primary



  Secondary




  Secondary




Top of rack switch

Rack falls over

                     24
Primary



Secondary




Secondary




Loss of internet

Building burns dow

                   25
San Francisco

                 Primary



                Secondary




                Secondary

   Dallas




                            26
San Francisco

                                Primary    Priority 1

                               Secondary   Priority 1

                               Secondary   Priority 0
   Dallas


            Disaster recover data center. Will
            never become primary
            automatically.
                                                        27
San Francisco


                New York    Primary



                           Secondary




   Dallas                  Secondary




                                       28
Fast recovery

                29
Primary



Secondary
             Is this a good idea?
   Arbiter




                                    30
1

 Primary



Secondary




    Arbiter




              31
1             2

 Primary       Primary



Secondary     Secondary




    Arbiter       Arbiter




                            32
1             2               3

 Primary       Primary         Primary
                                            Full Sync


Secondary     Secondary       Secondary     Secondary




    Arbiter       Arbiter         Arbiter



                            Uh oh. Full Sync is going to use
                            a lot of resources on the
                            primary. So I may have
                            downtime or degraded
                            performance
                                                               33
1

 Primary



Secondary




Secondary




            34
1           2

 Primary     Primary



Secondary   Secondary




Secondary   Secondary




                        35
1           2             3

 Primary     Primary       Primary



Secondary   Secondary    Secondary   Secondary




Secondary   Secondary    Secondary     Full Sync


                        Sync can happen from
                        secondary, which will not impact
                        traffic on Primary.


                                                       36
• Avoid single points of failure
  – Separate racks
  – Separate data centers
• Avoid long recovery downtime
  – Use journaling
  – Use 3+ replicas
• Keep your actives close
  – Use priority to control where failovers happen

                                                     37
Q&A after this session

                         38

More Related Content

PPTX
Welcome to MongoDB Tokyo 2012
PDF
Intro to NoSQL and MongoDB
PPT
Welcome and Introduction to A Morning with MongoDB Petah Tikvah
PDF
2012 mongo db_bangalore_replication
PDF
20121024 mongodb-boston (1)
PDF
Replication and Replica Sets
PPTX
Building your first Java Application with MongoDB
PDF
MongoDB Hadoop and Humongous Data
Welcome to MongoDB Tokyo 2012
Intro to NoSQL and MongoDB
Welcome and Introduction to A Morning with MongoDB Petah Tikvah
2012 mongo db_bangalore_replication
20121024 mongodb-boston (1)
Replication and Replica Sets
Building your first Java Application with MongoDB
MongoDB Hadoop and Humongous Data

Similar to Replication Online (20)

PPTX
Webinar: Replication and Replica Sets
PPTX
Mongosv 2011 - Replication
PPT
Lecture07_FaultTolerance in parallel and distributing
PPT
Lecture07_FaultTolerance in parallel and distributed
PDF
Replication and Replica Sets
PDF
Survey on replication techniques for distributed system
KEY
Replication, Durability, and Disaster Recovery
PDF
Fault tolerance review by tsegabrehan zerihun
PDF
Review of Some Checkpointing Schemes for Distributed and Mobile Computing Env...
PPTX
MongoDB Deployment Tips
PPT
File replication
PPTX
Fault tol final ppt.pptx
PPT
NFSv4 Replication for Grid Computing
PDF
Fusion method used to tolerate the faults occurred in disrtibuted system
PDF
10 replication
PPT
9 fault-tolerance
PPT
Chapter 14 replication
PPT
19. Distributed Databases in DBMS
PPTX
Fault tolerance in distributed systems
PDF
2013 london advanced-replication
Webinar: Replication and Replica Sets
Mongosv 2011 - Replication
Lecture07_FaultTolerance in parallel and distributing
Lecture07_FaultTolerance in parallel and distributed
Replication and Replica Sets
Survey on replication techniques for distributed system
Replication, Durability, and Disaster Recovery
Fault tolerance review by tsegabrehan zerihun
Review of Some Checkpointing Schemes for Distributed and Mobile Computing Env...
MongoDB Deployment Tips
File replication
Fault tol final ppt.pptx
NFSv4 Replication for Grid Computing
Fusion method used to tolerate the faults occurred in disrtibuted system
10 replication
9 fault-tolerance
Chapter 14 replication
19. Distributed Databases in DBMS
Fault tolerance in distributed systems
2013 london advanced-replication
Ad

More from MongoDB (20)

PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
PDF
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
PDF
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
PDF
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
PDF
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
PDF
MongoDB SoCal 2020: MongoDB Atlas Jump Start
PDF
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
PDF
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
PDF
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
PDF
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
PDF
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
PDF
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
PDF
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
PDF
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
PDF
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
PDF
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
PDF
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
Ad

Recently uploaded (20)

PPTX
operations management : demand supply ch
PPTX
svnfcksanfskjcsnvvjknsnvsdscnsncxasxa saccacxsax
PPTX
Astra-Investor- business Presentation (1).pptx
PDF
SIMNET Inc – 2023’s Most Trusted IT Services & Solution Provider
PPTX
sales presentation، Training Overview.pptx
PDF
THE COMPLETE GUIDE TO BUILDING PASSIVE INCOME ONLINE
PDF
Tata consultancy services case study shri Sharda college, basrur
PDF
BsN 7th Sem Course GridNNNNNNNN CCN.pdf
PDF
Comments on Crystal Cloud and Energy Star.pdf
PPTX
2025 Product Deck V1.0.pptxCATALOGTCLCIA
PPTX
Board-Reporting-Package-by-Umbrex-5-23-23.pptx
PDF
How to Get Business Funding for Small Business Fast
PDF
Digital Marketing & E-commerce Certificate Glossary.pdf.................
PDF
Introduction to Generative Engine Optimization (GEO)
PDF
1911 Gold Corporate Presentation Aug 2025.pdf
PDF
Family Law: The Role of Communication in Mediation (www.kiu.ac.ug)
PDF
Outsourced Audit & Assurance in USA Why Globus Finanza is Your Trusted Choice
PPTX
Slide gioi thieu VietinBank Quy 2 - 2025
PDF
NISM Series V-A MFD Workbook v December 2024.khhhjtgvwevoypdnew one must use ...
PPTX
Sales & Distribution Management , LOGISTICS, Distribution, Sales Managers
operations management : demand supply ch
svnfcksanfskjcsnvvjknsnvsdscnsncxasxa saccacxsax
Astra-Investor- business Presentation (1).pptx
SIMNET Inc – 2023’s Most Trusted IT Services & Solution Provider
sales presentation، Training Overview.pptx
THE COMPLETE GUIDE TO BUILDING PASSIVE INCOME ONLINE
Tata consultancy services case study shri Sharda college, basrur
BsN 7th Sem Course GridNNNNNNNN CCN.pdf
Comments on Crystal Cloud and Energy Star.pdf
2025 Product Deck V1.0.pptxCATALOGTCLCIA
Board-Reporting-Package-by-Umbrex-5-23-23.pptx
How to Get Business Funding for Small Business Fast
Digital Marketing & E-commerce Certificate Glossary.pdf.................
Introduction to Generative Engine Optimization (GEO)
1911 Gold Corporate Presentation Aug 2025.pdf
Family Law: The Role of Communication in Mediation (www.kiu.ac.ug)
Outsourced Audit & Assurance in USA Why Globus Finanza is Your Trusted Choice
Slide gioi thieu VietinBank Quy 2 - 2025
NISM Series V-A MFD Workbook v December 2024.khhhjtgvwevoypdnew one must use ...
Sales & Distribution Management , LOGISTICS, Distribution, Sales Managers

Replication Online

  • 1. Open source, high performance database Replication Summer 2012 1
  • 3. • High Availability (auto-failover) • Read Scaling (extra copies to read from) • Backups – Online, Delayed Copy (fat finger) – Point in Time (PiT) backups • Use (hidden) replica for secondary workload – Analytics – Data-processing – Integration with external systems 3
  • 4. Planned – Hardware upgrade – O/S or file-system tuning – Relocation of data to new file-system / storage – Software upgrade Unplanned – Hardware failure – Data center failure – Region outage – Human error – Application corruption 4
  • 5. • A cluster of N servers • All writes to primary • Reads can be to primary (default) or a secondary • Any (one) node can be primary • Consensus election of primary • Automatic failover • Automatic recovery 5
  • 6. Member 1 Member 3 Member 2 • Replica Set is made up of 2 or more nodes 6
  • 7. Member 1 Member 3 Member 2 Primary • Election establishes the PRIMARY • Data replication from PRIMARY to SECONDARY 7
  • 8. negotiate new master Member 1 Member 3 Member 2 DOWN • PRIMARY may fail • Automatic election of new PRIMARY if majority exists 8
  • 9. negotiate new master Member 3 Member 1 Primary Member 2 DOWN • New PRIMARY elected • Replica Set re-established 9
  • 10. Member 3 Member 1 Primary Member 2 Recovering • Automatic recovery 10
  • 11. Member 3 Member 1 Primary Member 2 • Replica Set re-established 11
  • 13. Primary As long as a partition Secondary can see a majority (>50%) of the Secondary cluster, then it will elect a primary. 13
  • 14. Primary 66% of cluster visible. Secondary Primary is elected Failed Node 14
  • 15. Secondary 33% of cluster visible. Failed Read only mode. Node Failed Node 15
  • 17. Primary 66% of cluster visible Secondary Primary is elected Primary Failed Secondary Node Secondary 17
  • 18. Primary Secondary Failed Node Failed Node Secondary Secondary 33% of cluster visible Read only mode. 18
  • 20. Secondary 50% of cluster visible Primary Secondary Read only mode. Failed Secondary Node Failed Node Secondary Secondary 20
  • 21. Primary Failed Node Secondary Failed Node Secondary Secondary 50% of cluster visible Secondary Read only mode. Secondary 21
  • 22. Avoid single points of failure 22
  • 23. 23
  • 24. Primary Secondary Secondary Top of rack switch Rack falls over 24
  • 26. San Francisco Primary Secondary Secondary Dallas 26
  • 27. San Francisco Primary Priority 1 Secondary Priority 1 Secondary Priority 0 Dallas Disaster recover data center. Will never become primary automatically. 27
  • 28. San Francisco New York Primary Secondary Dallas Secondary 28
  • 30. Primary Secondary Is this a good idea? Arbiter 30
  • 31. 1 Primary Secondary Arbiter 31
  • 32. 1 2 Primary Primary Secondary Secondary Arbiter Arbiter 32
  • 33. 1 2 3 Primary Primary Primary Full Sync Secondary Secondary Secondary Secondary Arbiter Arbiter Arbiter Uh oh. Full Sync is going to use a lot of resources on the primary. So I may have downtime or degraded performance 33
  • 35. 1 2 Primary Primary Secondary Secondary Secondary Secondary 35
  • 36. 1 2 3 Primary Primary Primary Secondary Secondary Secondary Secondary Secondary Secondary Secondary Full Sync Sync can happen from secondary, which will not impact traffic on Primary. 36
  • 37. • Avoid single points of failure – Separate racks – Separate data centers • Avoid long recovery downtime – Use journaling – Use 3+ replicas • Keep your actives close – Use priority to control where failovers happen 37
  • 38. Q&A after this session 38

Editor's Notes

  • #12: Change operations are written to the oplogThe oplog is a capped collection (fixed size)Must have enough space to allow new secondaries to catch up after copying from a primaryMust have enough space to cope with any applicable slaveDelaySecondaries query the primary's oplog and apply what they findAll replicas contain an oplog