SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Downloaden Sie, um offline zu lesen
Frankfurt NoSQL User Group
                                    Chris Harris
                            Email : charris@10gen.com
                               Twitter : cj_harris5



Wednesday, 22 February 12
As simple as possible,
                                        but no simpler
                                 Memcached
                                    Key / Value
     Scalability & Performance




                                                                    RDBMS




                                           Depth of functionality



Wednesday, 22 February 12
Key/Value Store
                            MongoDB
                            Relational Database




Wednesday, 22 February 12
Terminology

               RDBMS            MongoDB
               Table            Collection
               Row(s)           JSON Document
               Index            Index
               Join             Embedding & Linking
               Partition        Shard
               Partition Key    Shard Key


Wednesday, 22 February 12
Here is a “simple” SQL Model
       mysql> select * from book;
       +----+----------------------------------------------------------+
       | id | title                            |
       +----+----------------------------------------------------------+
       | 1 | The Demon-Haunted World: Science as a Candle in the Dark |
       | 2 | Cosmos                               |
       | 3 | Programming in Scala                     |
       +----+----------------------------------------------------------+
       3 rows in set (0.00 sec)

       mysql> select * from bookauthor;
       +---------+-----------+
       | book_id | author_id |
       +---------+-----------+
       |    1|       1|
       |    2|       1|
       |    3|       2|
       |    3|       3|
       |    3|       4|
       +---------+-----------+
       5 rows in set (0.00 sec)

       mysql> select * from author;
       +----+-----------+------------+-------------+-------------+---------------+
       | id | last_name | first_name | middle_name | nationality | year_of_birth |
       +----+-----------+------------+-------------+-------------+---------------+
       | 1 | Sagan    | Carl     | Edward    | NULL    | 1934         |
       | 2 | Odersky | Martin       | NULL     | DE     | 1958         |
       | 3 | Spoon    | Lex      | NULL     | NULL    | NULL         |
       | 4 | Venners | Bill      | NULL    | NULL     | NULL        |
       +----+-----------+------------+-------------+-------------+---------------+
       4 rows in set (0.00 sec)




Wednesday, 22 February 12
Flexible “Schemas”

              { “author”: “brendan”,
                “text”: “...” }

                                       { “author”: “brendan”,
                                         “text”: “...”,
                                         “tags”: [“mongodb”,
                                                “nosql”] }




Wednesday, 22 February 12
The Same Data in MongoDB

             {
           "_id" : ObjectId("4dfa6baa9c65dae09a4bbda5"),
           "title" : "Programming in Scala",
           "author" : [
               {
                  "first_name" : "Martin",
                  "last_name" : "Odersky",
                  "nationality" : "DE",
                  "year_of_birth" : 1958
               },
               {
                  "first_name" : "Lex",
                  "last_name" : "Spoon"
               },
               {
                  "first_name" : "Bill",
                  "last_name" : "Venners"
               }
           ]
       }




Wednesday, 22 February 12
CRUD Operations




Wednesday, 22 February 12
db.test.insert({fn: “Chris”, ln: “Harris”})




Wednesday, 22 February 12
db.test.find({fn: “Chris”})




Wednesday, 22 February 12
Cursors

                                 $gt, $lt, $gte, $lte, $ne, $all, $in, $nin, $or,
                               $not, $mod, $size, $exists, $type, $elemMatch


                       > var c = db.test.find({x: 20}).skip(20).limit(10)> c.next()
                       > c.next()
                       ...

                                                       query
                                             first N results + cursor id


                                               getMore w/ cursor id
                                           next N results + cursor id or 0
                                                         ...


Wednesday, 22 February 12
Creating Indexes
        An index on _id is automatic.
        For more use ensureIndex:


                     db.blogs.ensureIndex({author: 1})

                     1 = ascending
                     -1 = descending




Wednesday, 22 February 12
Compound Indexes


          db.blogs.save({
            author: "James",
            ts: new Date()
            ...
          });

          db.blogs.ensureIndex({author: 1, ts: -1})




Wednesday, 22 February 12
Unique Indexes


          db.blogs.save({
            author: "James",
            title: "My first blog"
            ...
          });

          db.blogs.ensureIndex({title: 1}, {unique: true})




Wednesday, 22 February 12
Indexing Embedded Documents
          db.blogs.save({
            title: "My First blog",
            stats : { views: 0,
                    followers: 0 }
          });

          db.blogs.ensureIndex({"stats.followers": -1})

          db.blogs.find({"stats.followers": {$gt: 500}})




Wednesday, 22 February 12
Indexing Embedded Arrays
          db.blogs.save({
            title: "My First blog",
            comments: [
              {author: "James", ts : new Date()} ]
          });

          db.blogs.ensureIndex({"comments.author": 1})

          db.blogs.find({"comments.author": "James"})




Wednesday, 22 February 12
Multikeys
          db.blogs.save({
            title: "My Second blog",
            tags: ["mongodb", "NoSQL"]
          });

          db.blogs.ensureIndex({tags: 1})

          db.blogs.find({tags: "NoSQL"})




Wednesday, 22 February 12
Covered Indexes
          • From 1.8.0
          • Query resolved in index only
          • Need to exclude _id from items projected
          db.blogs.save({
            author: "James",
            title: "My first blog"
          });

          db.blogs.ensureIndex({author: 1})

          db.blogs.find({author: "James"},
                   {author: 1, _id:0}))


Wednesday, 22 February 12
Sparse Indexes
          • From 1.8.0
          • Key value included if and only if the value is present
          • Reduces size of index
          • Limited to a single field
         db.blogs.ensureIndex({loc: 1}, {sparse: true})

         // loc key stored for Ben & Sarah only
         db.blogs.save({author: "Jim"})
         db.blogs.save({author: "Ben", loc: null})
         db.blogs.save({author: "Sarah", loc: "CA"})




Wednesday, 22 February 12
Geospatial
       • Geo hash stored in B-Tree
       • First two values indexed
          db.blogs.save({
            loc: { long: 40.739037, lat: 40.739037 }
          });

          db.blogs.save({
            loc: [40.739037, 40.739037]
          });

          db.blogs.ensureIndex({"loc": "2d"})




Wednesday, 22 February 12
Replication




Wednesday, 22 February 12
Types of outage

       • 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
Wednesday, 22 February 12
Replica Set features
           • A cluster of N servers
           • Any (one) node can be primary
           • Consensus election of primary
           • Automatic failover
           • Automatic recovery
           • All writes to primary
           • Reads can be to primary (default) or a secondary




Wednesday, 22 February 12
How MongoDB Replication works

                            Member
                              1               Member
                                                3




                                     Member
                                       2



    •Set is made up of 2 or more nodes


Wednesday, 22 February 12
How MongoDB Replication works

                            Member
                              1                Member
                                                 3




                                     Member
                                        2
                                     PRIMARY


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

Wednesday, 22 February 12
How MongoDB Replication works
                                        negotiate
                                       new master
                            Member
                              1                     Member
                                                      3




                                     Member
                                       2
                                     DOWN


    •PRIMARY may fail
    •Automatic election of new PRIMARY if majority
    exists
Wednesday, 22 February 12
How MongoDB Replication works

                            Member
                              1               Member
                                                 3
                                              PRIMARY




                                     Member
                                       2
                                     DOWN


    •New PRIMARY elected
    •Replication Set re-established

Wednesday, 22 February 12
How MongoDB Replication works

                            Member
                              1                   Member
                                                     3
                                                  PRIMARY




                                     Member 2
                                     RECOVERING




    •Automatic recovery


Wednesday, 22 February 12
How MongoDB Replication works

                            Member
                              1               Member
                                                 3
                                              PRIMARY




                                     Member
                                       2



    •Replication Set re-established


Wednesday, 22 February 12
Sharding




Wednesday, 22 February 12
http://community.qlikview.com/cfs-filesystemfile.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/
                           theqlikviewblog/Cutting-Grass-with-Scissors-_2D00_-2.jpg


Wednesday, 22 February 12
http://www.bitquill.net/blog/wp-content/uploads/2008/07/pack_of_harvesters.jpg

Wednesday, 22 February 12
MongoDB Scaling - Single Node
        read




                            node_a1




                                      write


Wednesday, 22 February 12
Write scaling - add Shards
        read


                            shard1    shard2


                            node_c1   node_c2


                            node_b1   node_b2


                            node_a1   node_a2




                                                write


Wednesday, 22 February 12
Write scaling - add Shards
        read


                            shard1    shard2    shard3


                            node_c1   node_c2   node_c3


                            node_b1   node_b2   node_b3


                            node_a1   node_a2   node_a3




                                                          write


Wednesday, 22 February 12
MongoDB Sharding

       • Automatic partitioning and management
       • Range based
       • Convert to sharded system with no downtime
       • Fully consistent




Wednesday, 22 February 12
How MongoDB Sharding works

       > db.posts.save( {age:40} )



                            -∞   +∞  

             -∞   40              41 +∞  



    •Data in inserted
    •Ranges are split into more “chunks”
Wednesday, 22 February 12
How MongoDB Sharding works

       > db.posts.save( {age:40} )
       > db.posts.save( {age:50} )


                            -∞   +∞  

             -∞   40              41 +∞  

                             41   50    51 +∞  

    •More Data in inserted
    •Ranges are split into more“chunks”
Wednesday, 22 February 12
How MongoDB Sharding works

       > db.posts.save( {age:40} )
       > db.posts.save( {age:50} )
       > db.posts.save( {age:60} )

                            -∞   +∞  

             -∞   40              41 +∞  

                             41   50    51 +∞  

                                   51   60   61 +∞  


Wednesday, 22 February 12
Balancing
                                                          mongos
                                                                                                      config
                                                          balancer
                                                                                                      config
              Chunks!
                                                                                                      config




                  1         2   3    4    13    14   15   16         25    26   27   28   37    38   39   40

                  5         6   7    8    17    18   19   20         29    30   31   32   41    42   43   44

                  9     10      11   12   21    22   23   24         33    34   35   36   45    46   47   48


                      Shard 1                  Shard 2                    Shard 3              Shard 4




Wednesday, 22 February 12
Balancing
                                                            mongos
                                                                                                        config
                                                            balancer
                                                                                                        config


                                          Imbalance
                                           Imbalance                                                    config




                  1         2   3    4

                  5         6   7    8

                  9     10      11   12     21    22   23   24         33    34   35   36   45    46   47   48


                      Shard 1                    Shard 2                    Shard 3              Shard 4




Wednesday, 22 February 12
Balancing
                                                          mongos
                                                                                                      config
                                                          balancer
                                                                                                      config

                                                 Move chunk 1 to                                      config
                                                 Shard 2




                  1         2   3    4

                  5         6   7    8

                  9     10      11   12   21    22   23   24         33    34   35   36   45    46   47   48


                      Shard 1                  Shard 2                    Shard 3              Shard 4




Wednesday, 22 February 12
Balancing
                                                          mongos
                                                                                                      config
                                                          balancer
                                                                                                      config

                                                                                                      config




                  1         2   3    4

                  5         6   7    8

                  9     10      11   12   21    22   23   24         33    34   35   36   45    46   47   48


                      Shard 1                  Shard 2                    Shard 3              Shard 4




Wednesday, 22 February 12
Balancing
                                                          mongos
                                                                                                      config
                                                          balancer
                                                                                                      config

                                                                                                      config




                            2   3    4

                  5         6   7    8    1

                  9     10      11   12   21    22   23   24         33    34   35   36   45    46   47   48


                      Shard 1                  Shard 2                    Shard 3              Shard 4




Wednesday, 22 February 12
Balancing
                                                          mongos
                                                                                                      config
                                                          balancer
                                                                                                      config
                                                               Chunk 1 now lives on
                                                                    Shard 2
                                                                                                      config




                            2   3    4

                  5         6   7    8    1

                  9     10      11   12   21    22   23   24         33    34   35   36   45    46   47   48


                      Shard 1                  Shard 2                    Shard 3              Shard 4




Wednesday, 22 February 12

Weitere ähnliche Inhalte

Was ist angesagt?

Pinterest的数据库分片架构
Pinterest的数据库分片架构Pinterest的数据库分片架构
Pinterest的数据库分片架构
Tommy Chiu
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
MongoDB
 
MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema Design
Alex Litvinok
 
Building a Social Network with MongoDB
  Building a Social Network with MongoDB  Building a Social Network with MongoDB
Building a Social Network with MongoDB
Fred Chu
 

Was ist angesagt? (20)

Indexing Strategies to Help You Scale
Indexing Strategies to Help You ScaleIndexing Strategies to Help You Scale
Indexing Strategies to Help You Scale
 
Webinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in DocumentsWebinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in Documents
 
Pinterest的数据库分片架构
Pinterest的数据库分片架构Pinterest的数据库分片架构
Pinterest的数据库分片架构
 
Building a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and JavaBuilding a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and Java
 
MongoDB .local Chicago 2019: Using Client Side Encryption in MongoDB 4.2
MongoDB .local Chicago 2019: Using Client Side Encryption in MongoDB 4.2MongoDB .local Chicago 2019: Using Client Side Encryption in MongoDB 4.2
MongoDB .local Chicago 2019: Using Client Side Encryption in MongoDB 4.2
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
 
MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema Design
 
Webinar: Schema Design
Webinar: Schema DesignWebinar: Schema Design
Webinar: Schema Design
 
Building a Social Network with MongoDB
  Building a Social Network with MongoDB  Building a Social Network with MongoDB
Building a Social Network with MongoDB
 
Dev Jumpstart: Schema Design Best Practices
Dev Jumpstart: Schema Design Best PracticesDev Jumpstart: Schema Design Best Practices
Dev Jumpstart: Schema Design Best Practices
 
Indexing
IndexingIndexing
Indexing
 
Schema Design with MongoDB
Schema Design with MongoDBSchema Design with MongoDB
Schema Design with MongoDB
 
Storing tree structures with MongoDB
Storing tree structures with MongoDBStoring tree structures with MongoDB
Storing tree structures with MongoDB
 
MongoDB .local Munich 2019: Best Practices for Working with IoT and Time-seri...
MongoDB .local Munich 2019: Best Practices for Working with IoT and Time-seri...MongoDB .local Munich 2019: Best Practices for Working with IoT and Time-seri...
MongoDB .local Munich 2019: Best Practices for Working with IoT and Time-seri...
 
Choosing a Shard key
Choosing a Shard keyChoosing a Shard key
Choosing a Shard key
 
MongoDB .local Houston 2019: Using Client Side Encryption in MongoDB 4.2
MongoDB .local Houston 2019: Using Client Side Encryption in MongoDB 4.2MongoDB .local Houston 2019: Using Client Side Encryption in MongoDB 4.2
MongoDB .local Houston 2019: Using Client Side Encryption in MongoDB 4.2
 
5 Pitfalls to Avoid with MongoDB
5 Pitfalls to Avoid with MongoDB5 Pitfalls to Avoid with MongoDB
5 Pitfalls to Avoid with MongoDB
 
MongoDB dessi-codemotion
MongoDB dessi-codemotionMongoDB dessi-codemotion
MongoDB dessi-codemotion
 

Andere mochten auch

How to install the zwave plugin switch controller
How to install the zwave plugin switch controllerHow to install the zwave plugin switch controller
How to install the zwave plugin switch controller
LeolaHuffman
 
Don eppelheimer, trane
Don eppelheimer, traneDon eppelheimer, trane
Don eppelheimer, trane
Sarah El Akkad
 
Ovos trabalhados arte na casca de ovos
Ovos trabalhados   arte na casca de ovosOvos trabalhados   arte na casca de ovos
Ovos trabalhados arte na casca de ovos
Sel Selmha
 

Andere mochten auch (20)

How to install the zwave plugin switch controller
How to install the zwave plugin switch controllerHow to install the zwave plugin switch controller
How to install the zwave plugin switch controller
 
Don eppelheimer, trane
Don eppelheimer, traneDon eppelheimer, trane
Don eppelheimer, trane
 
How to Infuse Your Media Planning with Social Data - by Forrester & Networked...
How to Infuse Your Media Planning with Social Data - by Forrester & Networked...How to Infuse Your Media Planning with Social Data - by Forrester & Networked...
How to Infuse Your Media Planning with Social Data - by Forrester & Networked...
 
Ovos trabalhados arte na casca de ovos
Ovos trabalhados   arte na casca de ovosOvos trabalhados   arte na casca de ovos
Ovos trabalhados arte na casca de ovos
 
Fraudes digitais no mundo pós-SPED - ENECON - 17.6.2011
Fraudes digitais no mundo pós-SPED - ENECON - 17.6.2011Fraudes digitais no mundo pós-SPED - ENECON - 17.6.2011
Fraudes digitais no mundo pós-SPED - ENECON - 17.6.2011
 
Quinto a
Quinto aQuinto a
Quinto a
 
Introduction to Ext JS 4
Introduction to Ext JS 4Introduction to Ext JS 4
Introduction to Ext JS 4
 
Pesquisa AvançAda Na Internet 2009
Pesquisa AvançAda Na Internet 2009Pesquisa AvançAda Na Internet 2009
Pesquisa AvançAda Na Internet 2009
 
Infolitigpart1
Infolitigpart1Infolitigpart1
Infolitigpart1
 
Curso de marketing em mídias sociais
Curso de marketing em mídias sociaisCurso de marketing em mídias sociais
Curso de marketing em mídias sociais
 
Adobe Digital Publishing Suite by dualpixel
Adobe Digital Publishing Suite by dualpixelAdobe Digital Publishing Suite by dualpixel
Adobe Digital Publishing Suite by dualpixel
 
00 a linguagem html
00 a linguagem html00 a linguagem html
00 a linguagem html
 
Daron Yöndem - ie8 Ebook Tr
Daron Yöndem - ie8 Ebook TrDaron Yöndem - ie8 Ebook Tr
Daron Yöndem - ie8 Ebook Tr
 
Ijm 06 10_012
Ijm 06 10_012Ijm 06 10_012
Ijm 06 10_012
 
Comparative analysis on E-Gov web sites
Comparative analysis on E-Gov web sitesComparative analysis on E-Gov web sites
Comparative analysis on E-Gov web sites
 
Java E
Java EJava E
Java E
 
Web Application Hacking 2004
Web Application Hacking 2004Web Application Hacking 2004
Web Application Hacking 2004
 
Unemployment
UnemploymentUnemployment
Unemployment
 
JSF2 and JSP
JSF2 and JSPJSF2 and JSP
JSF2 and JSP
 
document
documentdocument
document
 

Ähnlich wie MongoDB @ Frankfurt NoSql User Group

2012 mongo db_bangalore_roadmap_new
2012 mongo db_bangalore_roadmap_new2012 mongo db_bangalore_roadmap_new
2012 mongo db_bangalore_roadmap_new
MongoDB
 
De normalised london aggregation framework overview
De normalised london  aggregation framework overview De normalised london  aggregation framework overview
De normalised london aggregation framework overview
Chris Harris
 
MongoSV Schema Workshop
MongoSV Schema WorkshopMongoSV Schema Workshop
MongoSV Schema Workshop
MongoDB
 
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
boychatmate1
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Alex Bilbie
 
MongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL DatabaseMongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL Database
Ruben Inoto Soto
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling
DATAVERSITY
 

Ähnlich wie MongoDB @ Frankfurt NoSql User Group (20)

Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
2012 mongo db_bangalore_roadmap_new
2012 mongo db_bangalore_roadmap_new2012 mongo db_bangalore_roadmap_new
2012 mongo db_bangalore_roadmap_new
 
Starting with MongoDB
Starting with MongoDBStarting with MongoDB
Starting with MongoDB
 
De normalised london aggregation framework overview
De normalised london  aggregation framework overview De normalised london  aggregation framework overview
De normalised london aggregation framework overview
 
MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)
 
MongoSV Schema Workshop
MongoSV Schema WorkshopMongoSV Schema Workshop
MongoSV Schema Workshop
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDB
 
Use Your MySQL Knowledge to Become a MongoDB Guru
Use Your MySQL Knowledge to Become a MongoDB GuruUse Your MySQL Knowledge to Become a MongoDB Guru
Use Your MySQL Knowledge to Become a MongoDB Guru
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev Teams
 
Latinoware
LatinowareLatinoware
Latinoware
 
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
 
Grails 2.0 Update
Grails 2.0 UpdateGrails 2.0 Update
Grails 2.0 Update
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
MongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL DatabaseMongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL Database
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling
 
Webscale PostgreSQL - JSONB and Horizontal Scaling Strategies
Webscale PostgreSQL - JSONB and Horizontal Scaling StrategiesWebscale PostgreSQL - JSONB and Horizontal Scaling Strategies
Webscale PostgreSQL - JSONB and Horizontal Scaling Strategies
 
MySQL 开发
MySQL 开发MySQL 开发
MySQL 开发
 
2012 phoenix mug
2012 phoenix mug2012 phoenix mug
2012 phoenix mug
 
MongoDB at GUL
MongoDB at GULMongoDB at GUL
MongoDB at GUL
 
Getting Started with MongoDB (TCF ITPC 2014)
Getting Started with MongoDB (TCF ITPC 2014)Getting Started with MongoDB (TCF ITPC 2014)
Getting Started with MongoDB (TCF ITPC 2014)
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

MongoDB @ Frankfurt NoSql User Group

  • 1. Frankfurt NoSQL User Group Chris Harris Email : charris@10gen.com Twitter : cj_harris5 Wednesday, 22 February 12
  • 2. As simple as possible, but no simpler Memcached Key / Value Scalability & Performance RDBMS Depth of functionality Wednesday, 22 February 12
  • 3. Key/Value Store MongoDB Relational Database Wednesday, 22 February 12
  • 4. Terminology RDBMS MongoDB Table Collection Row(s) JSON Document Index Index Join Embedding & Linking Partition Shard Partition Key Shard Key Wednesday, 22 February 12
  • 5. Here is a “simple” SQL Model mysql> select * from book; +----+----------------------------------------------------------+ | id | title | +----+----------------------------------------------------------+ | 1 | The Demon-Haunted World: Science as a Candle in the Dark | | 2 | Cosmos | | 3 | Programming in Scala | +----+----------------------------------------------------------+ 3 rows in set (0.00 sec) mysql> select * from bookauthor; +---------+-----------+ | book_id | author_id | +---------+-----------+ | 1| 1| | 2| 1| | 3| 2| | 3| 3| | 3| 4| +---------+-----------+ 5 rows in set (0.00 sec) mysql> select * from author; +----+-----------+------------+-------------+-------------+---------------+ | id | last_name | first_name | middle_name | nationality | year_of_birth | +----+-----------+------------+-------------+-------------+---------------+ | 1 | Sagan | Carl | Edward | NULL | 1934 | | 2 | Odersky | Martin | NULL | DE | 1958 | | 3 | Spoon | Lex | NULL | NULL | NULL | | 4 | Venners | Bill | NULL | NULL | NULL | +----+-----------+------------+-------------+-------------+---------------+ 4 rows in set (0.00 sec) Wednesday, 22 February 12
  • 6. Flexible “Schemas” { “author”: “brendan”, “text”: “...” } { “author”: “brendan”, “text”: “...”, “tags”: [“mongodb”, “nosql”] } Wednesday, 22 February 12
  • 7. The Same Data in MongoDB { "_id" : ObjectId("4dfa6baa9c65dae09a4bbda5"), "title" : "Programming in Scala", "author" : [ { "first_name" : "Martin", "last_name" : "Odersky", "nationality" : "DE", "year_of_birth" : 1958 }, { "first_name" : "Lex", "last_name" : "Spoon" }, { "first_name" : "Bill", "last_name" : "Venners" } ] } Wednesday, 22 February 12
  • 9. db.test.insert({fn: “Chris”, ln: “Harris”}) Wednesday, 22 February 12
  • 11. Cursors $gt, $lt, $gte, $lte, $ne, $all, $in, $nin, $or, $not, $mod, $size, $exists, $type, $elemMatch > var c = db.test.find({x: 20}).skip(20).limit(10)> c.next() > c.next() ... query first N results + cursor id getMore w/ cursor id next N results + cursor id or 0 ... Wednesday, 22 February 12
  • 12. Creating Indexes An index on _id is automatic. For more use ensureIndex: db.blogs.ensureIndex({author: 1}) 1 = ascending -1 = descending Wednesday, 22 February 12
  • 13. Compound Indexes db.blogs.save({ author: "James", ts: new Date() ... }); db.blogs.ensureIndex({author: 1, ts: -1}) Wednesday, 22 February 12
  • 14. Unique Indexes db.blogs.save({ author: "James", title: "My first blog" ... }); db.blogs.ensureIndex({title: 1}, {unique: true}) Wednesday, 22 February 12
  • 15. Indexing Embedded Documents db.blogs.save({ title: "My First blog", stats : { views: 0, followers: 0 } }); db.blogs.ensureIndex({"stats.followers": -1}) db.blogs.find({"stats.followers": {$gt: 500}}) Wednesday, 22 February 12
  • 16. Indexing Embedded Arrays db.blogs.save({ title: "My First blog", comments: [ {author: "James", ts : new Date()} ] }); db.blogs.ensureIndex({"comments.author": 1}) db.blogs.find({"comments.author": "James"}) Wednesday, 22 February 12
  • 17. Multikeys db.blogs.save({ title: "My Second blog", tags: ["mongodb", "NoSQL"] }); db.blogs.ensureIndex({tags: 1}) db.blogs.find({tags: "NoSQL"}) Wednesday, 22 February 12
  • 18. Covered Indexes • From 1.8.0 • Query resolved in index only • Need to exclude _id from items projected db.blogs.save({ author: "James", title: "My first blog" }); db.blogs.ensureIndex({author: 1}) db.blogs.find({author: "James"}, {author: 1, _id:0})) Wednesday, 22 February 12
  • 19. Sparse Indexes • From 1.8.0 • Key value included if and only if the value is present • Reduces size of index • Limited to a single field db.blogs.ensureIndex({loc: 1}, {sparse: true}) // loc key stored for Ben & Sarah only db.blogs.save({author: "Jim"}) db.blogs.save({author: "Ben", loc: null}) db.blogs.save({author: "Sarah", loc: "CA"}) Wednesday, 22 February 12
  • 20. Geospatial • Geo hash stored in B-Tree • First two values indexed db.blogs.save({ loc: { long: 40.739037, lat: 40.739037 } }); db.blogs.save({ loc: [40.739037, 40.739037] }); db.blogs.ensureIndex({"loc": "2d"}) Wednesday, 22 February 12
  • 22. Types of outage • 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 Wednesday, 22 February 12
  • 23. Replica Set features • A cluster of N servers • Any (one) node can be primary • Consensus election of primary • Automatic failover • Automatic recovery • All writes to primary • Reads can be to primary (default) or a secondary Wednesday, 22 February 12
  • 24. How MongoDB Replication works Member 1 Member 3 Member 2 •Set is made up of 2 or more nodes Wednesday, 22 February 12
  • 25. How MongoDB Replication works Member 1 Member 3 Member 2 PRIMARY •Election establishes the PRIMARY •Data replication from PRIMARY to SECONDARY Wednesday, 22 February 12
  • 26. How MongoDB Replication works negotiate new master Member 1 Member 3 Member 2 DOWN •PRIMARY may fail •Automatic election of new PRIMARY if majority exists Wednesday, 22 February 12
  • 27. How MongoDB Replication works Member 1 Member 3 PRIMARY Member 2 DOWN •New PRIMARY elected •Replication Set re-established Wednesday, 22 February 12
  • 28. How MongoDB Replication works Member 1 Member 3 PRIMARY Member 2 RECOVERING •Automatic recovery Wednesday, 22 February 12
  • 29. How MongoDB Replication works Member 1 Member 3 PRIMARY Member 2 •Replication Set re-established Wednesday, 22 February 12
  • 31. http://community.qlikview.com/cfs-filesystemfile.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/ theqlikviewblog/Cutting-Grass-with-Scissors-_2D00_-2.jpg Wednesday, 22 February 12
  • 33. MongoDB Scaling - Single Node read node_a1 write Wednesday, 22 February 12
  • 34. Write scaling - add Shards read shard1 shard2 node_c1 node_c2 node_b1 node_b2 node_a1 node_a2 write Wednesday, 22 February 12
  • 35. Write scaling - add Shards read shard1 shard2 shard3 node_c1 node_c2 node_c3 node_b1 node_b2 node_b3 node_a1 node_a2 node_a3 write Wednesday, 22 February 12
  • 36. MongoDB Sharding • Automatic partitioning and management • Range based • Convert to sharded system with no downtime • Fully consistent Wednesday, 22 February 12
  • 37. How MongoDB Sharding works > db.posts.save( {age:40} ) -∞   +∞   -∞   40 41 +∞   •Data in inserted •Ranges are split into more “chunks” Wednesday, 22 February 12
  • 38. How MongoDB Sharding works > db.posts.save( {age:40} ) > db.posts.save( {age:50} ) -∞   +∞   -∞   40 41 +∞   41 50 51 +∞   •More Data in inserted •Ranges are split into more“chunks” Wednesday, 22 February 12
  • 39. How MongoDB Sharding works > db.posts.save( {age:40} ) > db.posts.save( {age:50} ) > db.posts.save( {age:60} ) -∞   +∞   -∞   40 41 +∞   41 50 51 +∞   51 60 61 +∞   Wednesday, 22 February 12
  • 40. Balancing mongos config balancer config Chunks! config 1 2 3 4 13 14 15 16 25 26 27 28 37 38 39 40 5 6 7 8 17 18 19 20 29 30 31 32 41 42 43 44 9 10 11 12 21 22 23 24 33 34 35 36 45 46 47 48 Shard 1 Shard 2 Shard 3 Shard 4 Wednesday, 22 February 12
  • 41. Balancing mongos config balancer config Imbalance Imbalance config 1 2 3 4 5 6 7 8 9 10 11 12 21 22 23 24 33 34 35 36 45 46 47 48 Shard 1 Shard 2 Shard 3 Shard 4 Wednesday, 22 February 12
  • 42. Balancing mongos config balancer config Move chunk 1 to config Shard 2 1 2 3 4 5 6 7 8 9 10 11 12 21 22 23 24 33 34 35 36 45 46 47 48 Shard 1 Shard 2 Shard 3 Shard 4 Wednesday, 22 February 12
  • 43. Balancing mongos config balancer config config 1 2 3 4 5 6 7 8 9 10 11 12 21 22 23 24 33 34 35 36 45 46 47 48 Shard 1 Shard 2 Shard 3 Shard 4 Wednesday, 22 February 12
  • 44. Balancing mongos config balancer config config 2 3 4 5 6 7 8 1 9 10 11 12 21 22 23 24 33 34 35 36 45 46 47 48 Shard 1 Shard 2 Shard 3 Shard 4 Wednesday, 22 February 12
  • 45. Balancing mongos config balancer config Chunk 1 now lives on Shard 2 config 2 3 4 5 6 7 8 1 9 10 11 12 21 22 23 24 33 34 35 36 45 46 47 48 Shard 1 Shard 2 Shard 3 Shard 4 Wednesday, 22 February 12