SlideShare une entreprise Scribd logo
1  sur  62
Télécharger pour lire hors ligne
MongoDB Basic Concepts

                                  Norberto Leite

                          Senior Solutions Architect, EMEA
                               norberto@10gen.com
                                       @nleite




Sunday, 21 October 12
Agenda

       •Overview
       •Replication
       •Scalability
       •Consistency & Durability
       •Flexibility, Developer Experienc




Sunday, 21 October 12
Your data needs started here...




                                  http://bit.ly/OT71M4
Sunday, 21 October 12
...but soon you had to be here




                                  http://bit.ly/Oxcsis

Sunday, 21 October 12
Basic Concepts
                           Application    Document
                                          Oriented
         High                             { author : “steve”,
                                            date : new Date(),
                                            text : “About MongoDB...”,
     Performance                            tags : [“tech”, “database”]}




                                            Fully
                                          Consistent

                  Horizontally Scalable

Sunday, 21 October 12
Tradeoff: Scale vs Functionality

                                    • memcached
        scalability & performance




                                       •key/value



                                                                     • RDBMS



                                            depth of functionality
Sunday, 21 October 12
Replication




Sunday, 21 October 12
Why do we need replication

       •Failover
       •Backups
       •Secondary batch jobs
       •High availability




Sunday, 21 October 12
Replica Sets
       Data Availability across nodes
       • Data Protection
         • Multiple copies of the data
         • Spread across Data Centers, AZs
       • High Availability
         • Automated Failover
         • Automated Recovery




Sunday, 21 October 12
Replica Sets


                App     Write
                                 Primary
                                            Asynchronous
                        Read                 Replication

                                Secondary
                        Read


                                Secondary
                        Read




Sunday, 21 October 12
Replica Sets


                App     Write
                                 Primary
                        Read

                                Secondary
                        Read


                                Secondary
                        Read




Sunday, 21 October 12
Replica Sets


                App
                                 Primary

                        Write
                                 Primary    Automatic Election of
                                                new Primary
                        Read

                                Secondary
                        Read




Sunday, 21 October 12
Replica Sets


                App
                                Recovering

                        Write                New primary serves
                                 Primary            data
                        Read

                                Secondary
                        Read




Sunday, 21 October 12
Replica Sets


                App
                                Secondary
                        Read

                        Write
                                 Primary
                        Read

                                Secondary
                        Read




Sunday, 21 October 12
Scalability




Sunday, 21 October 12
Horizontal Scalability




Sunday, 21 October 12
Sharding
       Data Distribution across nodes
       • Data location transparent to your code
       • Data distribution is automatic
       • Data re-distribution is automatic
       • Aggregate system resources horizontally
       • No code changes




Sunday, 21 October 12
Sharding - Range distribution

                        sh.shardCollection("test.tweets", {_id: 1} , false)


                        shard01                     shard02                   shard03




Sunday, 21 October 12
Sharding - Range distribution


                        shard01   shard02   shard03

                         a-i        j-r      s-z




Sunday, 21 October 12
Sharding - Splits


                        shard01   shard02   shard03

                         a-i      ja-jz      s-z
                                   k-r




Sunday, 21 October 12
Sharding - Splits


                        shard01   shard02   shard03

                         a-i       ja-ji     s-z
                                   ji-js
                                  js-jw
                                   jz-r

Sunday, 21 October 12
Sharding - Auto Balancing


                        shard01   shard02   shard03

                         a-i       ja-ji     s-z
                                   ji-js
                        js-jw     js-jw
                                   jz-r      jz-r

Sunday, 21 October 12
Sharding - Auto Balancing


                        shard01   shard02   shard03

                         a-i       ja-ji     n-z
                                   ji-js
                        js-jw
                                             jz-r

Sunday, 21 October 12
Sharding - Routed Query
                                            find({_id: "norberto"})




                        shard01   shard02                  shard03

                         a-i       ja-ji                     n-z
                                   ji-js
                        js-jw
                                                             jz-r

Sunday, 21 October 12
Sharding - Routed Query
                                            find({_id: "norberto"})




                        shard01   shard02                  shard03

                         a-i       ja-ji                     n-z
                                   ji-js
                        js-jw
                                                             jz-r

Sunday, 21 October 12
Sharding - Scatter Gather
                                       find({email: "norberto@10gen.com"})




                        shard01   shard02                shard03

                         a-i       ja-ji                  n-z
                                   ji-js
                        js-jw
                                                          jz-r

Sunday, 21 October 12
Sharding - Scatter Gather
                                       find({email: "norberto@10gen.com"})




                        shard01   shard02                shard03

                         a-i       ja-ji                  n-z
                                   ji-js
                        js-jw
                                                          jz-r

Sunday, 21 October 12
Sharding - Caching
                         96 GB Mem
                        3:1 Data/Mem


                        shard01

                           a-i
     300 GB Data




                           j-r
                          n-z

                          300 GB



Sunday, 21 October 12
Aggregate Horizontal Resources
                         96 GB Mem      96 GB Mem      96 GB Mem
                        1:1 Data/Mem   1:1 Data/Mem   1:1 Data/Mem


                        shard01        shard02        shard03

                           a-i            j-r           n-z
     300 GB Data




                          100 GB         100 GB        100 GB


Sunday, 21 October 12
Consistency & Durability




Sunday, 21 October 12
Two choices for consistency

       •Eventual consistency
                •Allow updates when a system has been partitioned
                •Resolve conflicts later
                •Example: CouchDB, Cassandra

       •Immediate consistency
                •Limit the application of updates to a single master
                node for a given slice of data
                        •Another node can take over after a failure is detected
                •Avoids the possibility of conflicts
                •Example: MongoDB



Sunday, 21 October 12
Durability

       •For how long is my data available?
       •When do I now that my data is safe?
       •Where?
       •Mongodb style
                •Fire and Forget
                •Get Last Error
                •Journal Sync
                •Replica Safe



Sunday, 21 October 12
Fire and Forget
               Driver   Primary




Sunday, 21 October 12
Fire and Forget
               Driver           Primary

                        write




Sunday, 21 October 12
Fire and Forget
               Driver           Primary

                        write

                                          apply in memory




Sunday, 21 October 12
Get Last Error
               Driver   Primary




Sunday, 21 October 12
Get Last Error
               Driver           Primary
                        write

                   getLastError




Sunday, 21 October 12
Get Last Error
               Driver           Primary
                        write

                   getLastError
                                          apply in memory




Sunday, 21 October 12
Get Last Error
               Driver           Primary
                        write

                   getLastError
                                          apply in memory




Sunday, 21 October 12
Journal Sync
               Driver   Primary




Sunday, 21 October 12
Journal Sync
               Driver           Primary
                        write

                   getLastError
                                          apply in memory
                      j:true




Sunday, 21 October 12
Journal Sync
               Driver           Primary
                        write

                   getLastError
                                          apply in memory
                      j:true
                                          write to journal




Sunday, 21 October 12
Journal Sync
               Driver           Primary
                        write

                   getLastError
                                          apply in memory
                      j:true
                                          write to journal




Sunday, 21 October 12
Replicas Safe
               Driver   Primary   Secondary




Sunday, 21 October 12
Replicas Safe
               Driver           Primary                     Secondary

                        write

                   getLastError
                        w:2               apply in memory




Sunday, 21 October 12
Replicas Safe
               Driver           Primary                     Secondary

                        write

                   getLastError
                        w:2               apply in memory
                                             replicate




Sunday, 21 October 12
Replicas Safe
               Driver           Primary                     Secondary

                        write

                   getLastError
                        w:2               apply in memory
                                             replicate




Sunday, 21 October 12
Flexibility




Sunday, 21 October 12
What MongoDB solves

                                  • Applications store complex data that is easier to
                        Agility   •
                                                 model as documents
                                      Schemaless DB enables faster development cycles




                                  • Relaxed transactional semantics enable easy scale
                    Flexibility   •
                                                           out
                                         Auto Sharding for scale down and scale up




                                  •      Cost effective operationalize abundant data
                         Cost                 (clickstreams, logs, tweets, ...)




Sunday, 21 October 12
Challenges for Databases

       ✓ Build a database for scaleout
                • Run on clusters of 100s of commodity
                machines

       •… that enables agile development

       •… and is usable for a broad variety of applications




Sunday, 21 October 12
Data Model

       • Why JSON?
                • Provides a simple, well understood
                encapsulation of data
                • Maps simply to the object in your OO language
                • Linking & Embedding to describe relationships




Sunday, 21 October 12
Json




        place1 = {
        
 name : "10gen HQ",
        
 address : "578 Broadway 7th Floor",
        
 city : "New York",
        
   zip : "10011",
           tags : [ "business", "tech" ]
        }
Sunday, 21 October 12
Schema Design
       Relational Database




Sunday, 21 October 12
Schema Design
       MongoDB                    embedding




                        linking
Sunday, 21 October 12
Schemas in MongoDB

     Design documents that simply map to
     your application
     post = {author: "Hergé",
          date: new Date(),
          text: "Destination Moon",
          tags: ["comic", "adventure"]}

     > db.posts.save(post)


Sunday, 21 October 12
Embedding
       > db.blogs.find( { author: "Hergé"} )

         { _id : ObjectId("4c4ba5c0672c685e5e8aabf3"),
           author : "Hergé",
           date : ISODate("2011-09-18T09:56:06.298Z"),
           text : "Destination Moon",
           tags : [ "comic", "adventure" ],
           comments : [
   !         {
   !       !    author : "Kyle",
   !       !    date : ISODate("2011-09-19T09:56:06.298Z"),
   !       !    text : "great book"
   !         }
           ]
         }




Sunday, 21 October 12
JSON & Scaleout

       • Embedding removes need for
                • Distributed Joins
                • Two Phase commit
       • Enables data to be distributed across many nodes
       without penalty




Sunday, 21 October 12
http://bit.ly/UmUnsU
Sunday, 21 October 12
http://bit.ly/cnP77L
Sunday, 21 October 12
http://bit.ly/ODoMhh
Sunday, 21 October 12
http://bit.ly/uW2nk
Sunday, 21 October 12
Sunday, 21 October 12

Contenu connexe

Similaire à A Morning with MongoDB Barcelona: MongoDB Basic Concepts

HeavenORHell,MongoDB
HeavenORHell,MongoDBHeavenORHell,MongoDB
HeavenORHell,MongoDBKenzou Yeh
 
A Morning with MongoDB Barcelona: Introduction
A Morning with MongoDB Barcelona: IntroductionA Morning with MongoDB Barcelona: Introduction
A Morning with MongoDB Barcelona: IntroductionMongoDB
 
Scala dsls-dissecting-and-implementing-rogue
Scala dsls-dissecting-and-implementing-rogueScala dsls-dissecting-and-implementing-rogue
Scala dsls-dissecting-and-implementing-rogueKonrad Malawski
 
Secrets of the asset pipeline
Secrets of the asset pipelineSecrets of the asset pipeline
Secrets of the asset pipelineKen Collins
 
Municipal Government Meets NoSQL
Municipal Government Meets NoSQLMunicipal Government Meets NoSQL
Municipal Government Meets NoSQLMongoDB
 
Peeling back your Network Layers with Security Onion
Peeling back your Network Layers with Security OnionPeeling back your Network Layers with Security Onion
Peeling back your Network Layers with Security OnionMark Hillick
 
Pinterest的数据库分片架构
Pinterest的数据库分片架构Pinterest的数据库分片架构
Pinterest的数据库分片架构Tommy Chiu
 
Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry BootcampAlvaro Videla
 
Architecting large Node.js applications
Architecting large Node.js applicationsArchitecting large Node.js applications
Architecting large Node.js applicationsSergi Mansilla
 
2012 DARIAH-EU Vienna - Research Environment Demonstrators (VCC1-task8)
2012 DARIAH-EU Vienna - Research Environment Demonstrators (VCC1-task8)2012 DARIAH-EU Vienna - Research Environment Demonstrators (VCC1-task8)
2012 DARIAH-EU Vienna - Research Environment Demonstrators (VCC1-task8)Dirk Roorda
 
MongoDB @ Frankfurt NoSql User Group
MongoDB @  Frankfurt NoSql User GroupMongoDB @  Frankfurt NoSql User Group
MongoDB @ Frankfurt NoSql User GroupChris Harris
 
Performance for Product Developers
Performance for Product DevelopersPerformance for Product Developers
Performance for Product DevelopersMatthew Wilkes
 

Similaire à A Morning with MongoDB Barcelona: MongoDB Basic Concepts (12)

HeavenORHell,MongoDB
HeavenORHell,MongoDBHeavenORHell,MongoDB
HeavenORHell,MongoDB
 
A Morning with MongoDB Barcelona: Introduction
A Morning with MongoDB Barcelona: IntroductionA Morning with MongoDB Barcelona: Introduction
A Morning with MongoDB Barcelona: Introduction
 
Scala dsls-dissecting-and-implementing-rogue
Scala dsls-dissecting-and-implementing-rogueScala dsls-dissecting-and-implementing-rogue
Scala dsls-dissecting-and-implementing-rogue
 
Secrets of the asset pipeline
Secrets of the asset pipelineSecrets of the asset pipeline
Secrets of the asset pipeline
 
Municipal Government Meets NoSQL
Municipal Government Meets NoSQLMunicipal Government Meets NoSQL
Municipal Government Meets NoSQL
 
Peeling back your Network Layers with Security Onion
Peeling back your Network Layers with Security OnionPeeling back your Network Layers with Security Onion
Peeling back your Network Layers with Security Onion
 
Pinterest的数据库分片架构
Pinterest的数据库分片架构Pinterest的数据库分片架构
Pinterest的数据库分片架构
 
Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry Bootcamp
 
Architecting large Node.js applications
Architecting large Node.js applicationsArchitecting large Node.js applications
Architecting large Node.js applications
 
2012 DARIAH-EU Vienna - Research Environment Demonstrators (VCC1-task8)
2012 DARIAH-EU Vienna - Research Environment Demonstrators (VCC1-task8)2012 DARIAH-EU Vienna - Research Environment Demonstrators (VCC1-task8)
2012 DARIAH-EU Vienna - Research Environment Demonstrators (VCC1-task8)
 
MongoDB @ Frankfurt NoSql User Group
MongoDB @  Frankfurt NoSql User GroupMongoDB @  Frankfurt NoSql User Group
MongoDB @ Frankfurt NoSql User Group
 
Performance for Product Developers
Performance for Product DevelopersPerformance for Product Developers
Performance for Product Developers
 

Plus de MongoDB

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

Plus de MongoDB (20)

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

A Morning with MongoDB Barcelona: MongoDB Basic Concepts

  • 1. MongoDB Basic Concepts Norberto Leite Senior Solutions Architect, EMEA norberto@10gen.com @nleite Sunday, 21 October 12
  • 2. Agenda •Overview •Replication •Scalability •Consistency & Durability •Flexibility, Developer Experienc Sunday, 21 October 12
  • 3. Your data needs started here... http://bit.ly/OT71M4 Sunday, 21 October 12
  • 4. ...but soon you had to be here http://bit.ly/Oxcsis Sunday, 21 October 12
  • 5. Basic Concepts Application Document Oriented High { author : “steve”, date : new Date(), text : “About MongoDB...”, Performance tags : [“tech”, “database”]} Fully Consistent Horizontally Scalable Sunday, 21 October 12
  • 6. Tradeoff: Scale vs Functionality • memcached scalability & performance •key/value • RDBMS depth of functionality Sunday, 21 October 12
  • 8. Why do we need replication •Failover •Backups •Secondary batch jobs •High availability Sunday, 21 October 12
  • 9. Replica Sets Data Availability across nodes • Data Protection • Multiple copies of the data • Spread across Data Centers, AZs • High Availability • Automated Failover • Automated Recovery Sunday, 21 October 12
  • 10. Replica Sets App Write Primary Asynchronous Read Replication Secondary Read Secondary Read Sunday, 21 October 12
  • 11. Replica Sets App Write Primary Read Secondary Read Secondary Read Sunday, 21 October 12
  • 12. Replica Sets App Primary Write Primary Automatic Election of new Primary Read Secondary Read Sunday, 21 October 12
  • 13. Replica Sets App Recovering Write New primary serves Primary data Read Secondary Read Sunday, 21 October 12
  • 14. Replica Sets App Secondary Read Write Primary Read Secondary Read Sunday, 21 October 12
  • 17. Sharding Data Distribution across nodes • Data location transparent to your code • Data distribution is automatic • Data re-distribution is automatic • Aggregate system resources horizontally • No code changes Sunday, 21 October 12
  • 18. Sharding - Range distribution sh.shardCollection("test.tweets", {_id: 1} , false) shard01 shard02 shard03 Sunday, 21 October 12
  • 19. Sharding - Range distribution shard01 shard02 shard03 a-i j-r s-z Sunday, 21 October 12
  • 20. Sharding - Splits shard01 shard02 shard03 a-i ja-jz s-z k-r Sunday, 21 October 12
  • 21. Sharding - Splits shard01 shard02 shard03 a-i ja-ji s-z ji-js js-jw jz-r Sunday, 21 October 12
  • 22. Sharding - Auto Balancing shard01 shard02 shard03 a-i ja-ji s-z ji-js js-jw js-jw jz-r jz-r Sunday, 21 October 12
  • 23. Sharding - Auto Balancing shard01 shard02 shard03 a-i ja-ji n-z ji-js js-jw jz-r Sunday, 21 October 12
  • 24. Sharding - Routed Query find({_id: "norberto"}) shard01 shard02 shard03 a-i ja-ji n-z ji-js js-jw jz-r Sunday, 21 October 12
  • 25. Sharding - Routed Query find({_id: "norberto"}) shard01 shard02 shard03 a-i ja-ji n-z ji-js js-jw jz-r Sunday, 21 October 12
  • 26. Sharding - Scatter Gather find({email: "norberto@10gen.com"}) shard01 shard02 shard03 a-i ja-ji n-z ji-js js-jw jz-r Sunday, 21 October 12
  • 27. Sharding - Scatter Gather find({email: "norberto@10gen.com"}) shard01 shard02 shard03 a-i ja-ji n-z ji-js js-jw jz-r Sunday, 21 October 12
  • 28. Sharding - Caching 96 GB Mem 3:1 Data/Mem shard01 a-i 300 GB Data j-r n-z 300 GB Sunday, 21 October 12
  • 29. Aggregate Horizontal Resources 96 GB Mem 96 GB Mem 96 GB Mem 1:1 Data/Mem 1:1 Data/Mem 1:1 Data/Mem shard01 shard02 shard03 a-i j-r n-z 300 GB Data 100 GB 100 GB 100 GB Sunday, 21 October 12
  • 31. Two choices for consistency •Eventual consistency •Allow updates when a system has been partitioned •Resolve conflicts later •Example: CouchDB, Cassandra •Immediate consistency •Limit the application of updates to a single master node for a given slice of data •Another node can take over after a failure is detected •Avoids the possibility of conflicts •Example: MongoDB Sunday, 21 October 12
  • 32. Durability •For how long is my data available? •When do I now that my data is safe? •Where? •Mongodb style •Fire and Forget •Get Last Error •Journal Sync •Replica Safe Sunday, 21 October 12
  • 33. Fire and Forget Driver Primary Sunday, 21 October 12
  • 34. Fire and Forget Driver Primary write Sunday, 21 October 12
  • 35. Fire and Forget Driver Primary write apply in memory Sunday, 21 October 12
  • 36. Get Last Error Driver Primary Sunday, 21 October 12
  • 37. Get Last Error Driver Primary write getLastError Sunday, 21 October 12
  • 38. Get Last Error Driver Primary write getLastError apply in memory Sunday, 21 October 12
  • 39. Get Last Error Driver Primary write getLastError apply in memory Sunday, 21 October 12
  • 40. Journal Sync Driver Primary Sunday, 21 October 12
  • 41. Journal Sync Driver Primary write getLastError apply in memory j:true Sunday, 21 October 12
  • 42. Journal Sync Driver Primary write getLastError apply in memory j:true write to journal Sunday, 21 October 12
  • 43. Journal Sync Driver Primary write getLastError apply in memory j:true write to journal Sunday, 21 October 12
  • 44. Replicas Safe Driver Primary Secondary Sunday, 21 October 12
  • 45. Replicas Safe Driver Primary Secondary write getLastError w:2 apply in memory Sunday, 21 October 12
  • 46. Replicas Safe Driver Primary Secondary write getLastError w:2 apply in memory replicate Sunday, 21 October 12
  • 47. Replicas Safe Driver Primary Secondary write getLastError w:2 apply in memory replicate Sunday, 21 October 12
  • 49. What MongoDB solves • Applications store complex data that is easier to Agility • model as documents Schemaless DB enables faster development cycles • Relaxed transactional semantics enable easy scale Flexibility • out Auto Sharding for scale down and scale up • Cost effective operationalize abundant data Cost (clickstreams, logs, tweets, ...) Sunday, 21 October 12
  • 50. Challenges for Databases ✓ Build a database for scaleout • Run on clusters of 100s of commodity machines •… that enables agile development •… and is usable for a broad variety of applications Sunday, 21 October 12
  • 51. Data Model • Why JSON? • Provides a simple, well understood encapsulation of data • Maps simply to the object in your OO language • Linking & Embedding to describe relationships Sunday, 21 October 12
  • 52. Json place1 = { name : "10gen HQ", address : "578 Broadway 7th Floor", city : "New York", zip : "10011", tags : [ "business", "tech" ] } Sunday, 21 October 12
  • 53. Schema Design Relational Database Sunday, 21 October 12
  • 54. Schema Design MongoDB embedding linking Sunday, 21 October 12
  • 55. Schemas in MongoDB Design documents that simply map to your application post = {author: "Hergé", date: new Date(), text: "Destination Moon", tags: ["comic", "adventure"]} > db.posts.save(post) Sunday, 21 October 12
  • 56. Embedding > db.blogs.find( { author: "Hergé"} ) { _id : ObjectId("4c4ba5c0672c685e5e8aabf3"), author : "Hergé", date : ISODate("2011-09-18T09:56:06.298Z"), text : "Destination Moon", tags : [ "comic", "adventure" ], comments : [ ! { ! ! author : "Kyle", ! ! date : ISODate("2011-09-19T09:56:06.298Z"), ! ! text : "great book" ! } ] } Sunday, 21 October 12
  • 57. JSON & Scaleout • Embedding removes need for • Distributed Joins • Two Phase commit • Enables data to be distributed across many nodes without penalty Sunday, 21 October 12