SlideShare uma empresa Scribd logo
1 de 17
MongoDB Live Coding Session
tobias.trelle@codecentric.de
@tobiastrelle
 codecentric AG
„It‘s not my fault the chapters are short,
  MongoDB is just easy to learn“

      from „The Little MongoDB book“




codecentric AG
MongoDB User Groups by codecentric



                  MongoDB User-Gruppe Düsseldorf
                 https://www.xing.com/net/mongodb-dus
                               @MongoDUS
                         Contact: Tobias Trelle




                 MongoDB User-Gruppe Frankfurt/Main
                  https://www.xing.com/net/mongodb-ffm
                          Contact: Uwe Seiler



codecentric AG
What is MongoDB?

      Named from „humongous“ = gigantic   http://www.mongodb.org


      NoSQL datastore, Open Source https://github.com/mongodb
      support from manufacturer 10gen http://www.10gen.com


      Highly scalable (scale-out)

      Stores so called „documents“


      Supports replication & sharding


      Map/Reduce


      Geospatial indexes / queries

codecentric AG
Basic structure of a MongoDB server


                           Server



                          Database
Relational counterpart                 But …
                                       Flexible
            Table         Collection
                                       Schema

                 Row      Document


                                        - Arrays
                 Column     Field
                                        - recursive
codecentric AG
What‘s a document?

      Single record that can be stored in a collection


      JSON = JavaScript Object Notation (internal representation BSON = Binary JSON)


      var doc =      {
                     title: „MongoDB_Live_Hacking.pptx“,
                     tags: [ „cc“, „mongodb“, „nosql“ ],
                     slides: [
                               { nr = 1, header = „MongoDB User Groups by codecentric“},
                               { nr = 2, header = „MongoDB at codedcentric WiKi“},
                               …
                               ]
                     };




codecentric AG
Live Session

      CRUD operations


      Queries


      Geospatial Queries


      Map/Reduce


      Replication


      Sharding


      Raw Java API & Spring Data API


codecentric AG
Geospatial Queries

      Queries based on
      2-dimensional coordinates


      _id: "A", position: [0.001, -0.002]
      _id: "B", position: [0.75, 0.75]
      _id: "C", position: [0.5, 0.5]
      _id: "D", position: [-0.5, -0.5]


      Queries based on distances
      & shapes


      Details:
      http://blog.codecentric.de/en/2012/02/spring-data-mongodb-geospatial-queries/




codecentric AG
Map/Reduce

      Data processing algorithm based on two phases: map & reduce


      Code execution co-located with the data


      Map phase can be run in parallel (on multiple nodes etc.) on huge data sets


      MongoDB map / reduce:

                 runs on a subset of / all documents of a collection


                 Map / Reduce algorithms are JS functions


                 Output documents of the map function are input to the reduce function


                 Results are documents stored in a target collection
codecentric AG
Map/Reduce example
      We want to count occurences of tags assigned to our documents:
          {name: „Doc 1“, tags: [ „cc“, „mongodb“, „nosql“ ] }
          {name: „Doc 2“, tags: [ „cc“, „agile“ ] }              Map output:
          {name: „Doc 3“, tags: [ „cc“ ] }                       key = „cc“, value = {count: 1}
                                                                              key = „mongodb“, value = {count: 1}
                                                                              key = „nosql“, value = {count: 1}
      Map function:
                                                                              key = „cc“, value = {count: 1}
      function() { this.tags.forEach( function(tag) {                         key = „agile“, value = {count: 1}
                       emit( tag, {count: 1} )                                key = „cc“, value = {count: 1}
                       })
      }
      Reduce function:                                  Reduce input:
      function(key, values) {                           key = „cc“, values = [ {count: 1}, {count: 1}, {count: 1} ]
             var result = {count: 0};
                                                        key = „mongodb“, values = [ {count: 1} ]
             values.forEach(function(value) {
                                                        key = „nosql“, values = [ {count: 1} ]
                       result.count += value.count;
                                                        key = „agile“, values = [ {count: 1} ]
             });
             return result;
      }
codecentric AG
MongoDB Replication

      A cluster is called „replica set“
      Uses Master/Slave replication
      Writes from clients go to the master only
      If the master goes down, the slaves elect a new master (n > 2)

                                                    Replica set w/ n = 3



                                                                           Slave 1

                 Client                    Master

                                                                           Slave 2



codecentric AG
MongoDB Sharding

      Data is distributed over n nodes, each record is persisted only once
      Data only on the shard nodes
      Config Server = book keeper, knows where the data is
      Switch: Gateway for clients

                                                  Sharding setup

                                Config
                                Server                                 Shard 1




                                                                        Shard 2
             Client             Switch


codecentric AG
MongoDB Sharding in Production

      Each shard is a replica set + 3 config servers




Source: http://www.mongodb.org/display/DOCS/Sharding+Introduction
codecentric AG
MongoDB Sharding Example: Initial State
mongos> sh.status()
--- Sharding Status ---
   sharding version: { "_id" : 1, "version" : 3 }
   shards:                                                                    2 Shards
             {   "_id" : "shard0000",     "host" : "tmp-pc:9000" }
             {   "_id" : "shard0001",     "host" : "tmp-pc:9001" }
   databases:
             {   "_id" : "admin",   "partitioned" : false,    "primary" : "config" }
             {   "_id" : "data",    "partitioned" : true,    "primary" : "shard0000" }
                      data.foo chunks:
                                         shard0000      1
                              { "age" : { $minKey : 1 } } -->> { "age" : { $maxKey : 1 } } on : shard0000 { "t" : 1000,
     "i" : 0 }




codecentric AG
MongoDB Sharding Example: Multiple Chunks
mongos> sh.status()
--- Sharding Status ---
   sharding version: { "_id" : 1, "version" : 3 }
   shards:                                                                    2 Shards
             {   "_id" : "shard0000",     "host" : "tmp-pc:9000" }
             {   "_id" : "shard0001",     "host" : "tmp-pc:9001" }
   databases:
             {   "_id" : "admin",   "partitioned" : false,    "primary" : "config" }
             {   "_id" : "data",    "partitioned" : true,    "primary" : "shard0000" }
                      data.foo chunks:
                                         shard0001      4
                                         shard0000      5
              Chunks
                              { "age" : { $minKey : 1 } } -->> { "age" : 50 } on : shard0001 { "t" : 2000, "i" : 0 }
            are equally
            distributed       { "age" : 50 } -->> { "age" : 53 } on : shard0001 { "t" : 3000, "i" : 0 }
                              { "age" : 53 } -->> { "age" : 54 } on : shard0001 { "t" : 4000, "i" : 0 }
                              { "age" : 54 } -->> { "age" : 58 } on : shard0001 { "t" : 5000, "i" : 0 }
                              { "age" : 58 } -->> { "age" : 60 } on : shard0000 { "t" : 5000, "i" : 1 }
                              { "age" : 60 } -->> { "age" : 63 } on : shard0000 { "t" : 1000, "i" : 14 }
                              { "age" : 63 } -->> { "age" : 65 } on : shard0000 { "t" : 1000, "i" : 11 }
                              { "age" : 65 } -->> { "age" : 69 } on : shard0000 { "t" : 1000, "i" : 12 }
                              { "age" : 69 } -->> { "age" : { $maxKey : 1 } } on : shard0000 { "t" : 1000, "i" : 4 }


codecentric AG
MongoDB API
      Drivers for many languages (Java, Ruby, PHP, C++, …)
      Low level Java API: MongoDB Java Driver
      Spring Data MongoDB: Repository Support + Objekt/Collection Mapping

                                                 Spring Data
                                       CrudRepository     PagingAndSortingRepository

                       Spring Data      Spring Data          Spring Data           Spring Data
                           JPA           MongoDB               Neo4j                    …
                      JpaRepository   MongoRepository      GraphRepository
                                      MongoTemplate         Neo4jTemplate


                                                           Embedded     REST


                           JPA        Mongo Java Driver

                          JDBC



                         RDBMS             MongoDB              Neo4j                   …




codecentric AG
QUESTION?

Tobias Trelle

codecentric AG
Merscheider Str. 1
42699 Solingen

tel              +49 (0) 212.233628.47
fax              +49 (0) 212.233628.79
mail             Tobias.Trelle@codecentric.de
twitter          @tobiastrelle

www.codecentric.de
www.mbg-online.de
blog.codecentric.de
www.xing.com/net/mongodb-dus


codecentric AG                                  20.08.2012   17

Mais conteúdo relacionado

Mais procurados

Introduction to Restkit
Introduction to RestkitIntroduction to Restkit
Introduction to Restkitpetertmarks
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBMongoDB
 
Morphia, Spring Data & Co.
Morphia, Spring Data & Co.Morphia, Spring Data & Co.
Morphia, Spring Data & Co.Tobias Trelle
 
Embracing the-power-of-refactor
Embracing the-power-of-refactorEmbracing the-power-of-refactor
Embracing the-power-of-refactorXiaojun REN
 
Getting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSGetting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSMongoDB
 
MongoDB .local Munich 2019: New Encryption Capabilities in MongoDB 4.2: A Dee...
MongoDB .local Munich 2019: New Encryption Capabilities in MongoDB 4.2: A Dee...MongoDB .local Munich 2019: New Encryption Capabilities in MongoDB 4.2: A Dee...
MongoDB .local Munich 2019: New Encryption Capabilities in MongoDB 4.2: A Dee...MongoDB
 
Java development with MongoDB
Java development with MongoDBJava development with MongoDB
Java development with MongoDBJames Williams
 
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...MongoDB
 
Java Development with MongoDB
Java Development with MongoDBJava Development with MongoDB
Java Development with MongoDBScott Hernandez
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile servicesAymeric Weinbach
 
MongoDB .local Munich 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pip...
MongoDB .local Munich 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pip...MongoDB .local Munich 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pip...
MongoDB .local Munich 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pip...MongoDB
 
Inside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source DatabaseInside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source DatabaseMike Dirolf
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMongoDB
 
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSuzquiano
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBTobias Trelle
 
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram VaswaniHigh Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswanivvaswani
 
Orion Context Broker NGSI-v2 Overview for Developers That Already Know Ngsi-v...
Orion Context Broker NGSI-v2 Overview for Developers That Already Know Ngsi-v...Orion Context Broker NGSI-v2 Overview for Developers That Already Know Ngsi-v...
Orion Context Broker NGSI-v2 Overview for Developers That Already Know Ngsi-v...Fermin Galan
 
What is the ServiceStack?
What is the ServiceStack?What is the ServiceStack?
What is the ServiceStack?Demis Bellot
 

Mais procurados (20)

Introduction to Restkit
Introduction to RestkitIntroduction to Restkit
Introduction to Restkit
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
Morphia, Spring Data & Co.
Morphia, Spring Data & Co.Morphia, Spring Data & Co.
Morphia, Spring Data & Co.
 
Embracing the-power-of-refactor
Embracing the-power-of-refactorEmbracing the-power-of-refactor
Embracing the-power-of-refactor
 
Getting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSGetting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJS
 
MongoDB .local Munich 2019: New Encryption Capabilities in MongoDB 4.2: A Dee...
MongoDB .local Munich 2019: New Encryption Capabilities in MongoDB 4.2: A Dee...MongoDB .local Munich 2019: New Encryption Capabilities in MongoDB 4.2: A Dee...
MongoDB .local Munich 2019: New Encryption Capabilities in MongoDB 4.2: A Dee...
 
Java development with MongoDB
Java development with MongoDBJava development with MongoDB
Java development 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...
 
Java Development with MongoDB
Java Development with MongoDBJava Development with MongoDB
Java Development with MongoDB
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile services
 
MongoDB .local Munich 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pip...
MongoDB .local Munich 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pip...MongoDB .local Munich 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pip...
MongoDB .local Munich 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pip...
 
Inside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source DatabaseInside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source Database
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
 
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMS
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram VaswaniHigh Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
 
Orion Context Broker NGSI-v2 Overview for Developers That Already Know Ngsi-v...
Orion Context Broker NGSI-v2 Overview for Developers That Already Know Ngsi-v...Orion Context Broker NGSI-v2 Overview for Developers That Already Know Ngsi-v...
Orion Context Broker NGSI-v2 Overview for Developers That Already Know Ngsi-v...
 
What is the ServiceStack?
What is the ServiceStack?What is the ServiceStack?
What is the ServiceStack?
 
Return of c++
Return of c++Return of c++
Return of c++
 

Destaque

Leigh lillis medical TW resume 8 2016
Leigh lillis medical TW resume 8 2016Leigh lillis medical TW resume 8 2016
Leigh lillis medical TW resume 8 2016Leigh Ellen Lillis
 
Meatco AGM 2012 - CEO Presentation
Meatco AGM 2012 - CEO PresentationMeatco AGM 2012 - CEO Presentation
Meatco AGM 2012 - CEO Presentationmeatconamibia
 
Ppt newton's law
Ppt newton's lawPpt newton's law
Ppt newton's lawmamardc
 
2012 Ford Fiesta Brochure | Mason City Ford, Waverly Ford, and Clear Lake Ford
2012 Ford Fiesta Brochure | Mason City Ford, Waverly Ford, and Clear Lake Ford2012 Ford Fiesta Brochure | Mason City Ford, Waverly Ford, and Clear Lake Ford
2012 Ford Fiesta Brochure | Mason City Ford, Waverly Ford, and Clear Lake FordIowa CarSales
 
what is Blubbr? and how to use it?
what is Blubbr? and how to use it?what is Blubbr? and how to use it?
what is Blubbr? and how to use it?Jihane Balsheh
 
Theanatomyofanentrepreneur 100105180411-phpapp01
Theanatomyofanentrepreneur 100105180411-phpapp01Theanatomyofanentrepreneur 100105180411-phpapp01
Theanatomyofanentrepreneur 100105180411-phpapp01Deepak R Gorad
 
Enhance WordPress Search Using Sphinx
Enhance WordPress Search Using SphinxEnhance WordPress Search Using Sphinx
Enhance WordPress Search Using SphinxRoshan Bhattarai
 
The Social Challenge of 1.5°C Webinar: Karen O'Brien
The Social Challenge of 1.5°C Webinar: Karen O'BrienThe Social Challenge of 1.5°C Webinar: Karen O'Brien
The Social Challenge of 1.5°C Webinar: Karen O'Brientewksjj
 
Power electronics projects
Power electronics projectsPower electronics projects
Power electronics projectsSenthil Kumar
 
Xamarin Mobile March 2014
Xamarin Mobile March 2014Xamarin Mobile March 2014
Xamarin Mobile March 2014Joe Koletar
 
Port folio 20121005
Port folio 20121005Port folio 20121005
Port folio 20121005Thành Mắm
 
deepak gorad Final csr
deepak gorad Final csrdeepak gorad Final csr
deepak gorad Final csrDeepak R Gorad
 
2012 Media Highlights
2012 Media Highlights2012 Media Highlights
2012 Media Highlightsmeatconamibia
 
2 power and hydrogen generation figures
2 power and hydrogen generation figures2 power and hydrogen generation figures
2 power and hydrogen generation figuresnovi5036
 

Destaque (20)

Leigh lillis medical TW resume 8 2016
Leigh lillis medical TW resume 8 2016Leigh lillis medical TW resume 8 2016
Leigh lillis medical TW resume 8 2016
 
Meatco AGM 2012 - CEO Presentation
Meatco AGM 2012 - CEO PresentationMeatco AGM 2012 - CEO Presentation
Meatco AGM 2012 - CEO Presentation
 
Windows7
Windows7Windows7
Windows7
 
Ppt newton's law
Ppt newton's lawPpt newton's law
Ppt newton's law
 
2012 Ford Fiesta Brochure | Mason City Ford, Waverly Ford, and Clear Lake Ford
2012 Ford Fiesta Brochure | Mason City Ford, Waverly Ford, and Clear Lake Ford2012 Ford Fiesta Brochure | Mason City Ford, Waverly Ford, and Clear Lake Ford
2012 Ford Fiesta Brochure | Mason City Ford, Waverly Ford, and Clear Lake Ford
 
Wireless projects
Wireless projectsWireless projects
Wireless projects
 
what is Blubbr? and how to use it?
what is Blubbr? and how to use it?what is Blubbr? and how to use it?
what is Blubbr? and how to use it?
 
Theanatomyofanentrepreneur 100105180411-phpapp01
Theanatomyofanentrepreneur 100105180411-phpapp01Theanatomyofanentrepreneur 100105180411-phpapp01
Theanatomyofanentrepreneur 100105180411-phpapp01
 
Enhance WordPress Search Using Sphinx
Enhance WordPress Search Using SphinxEnhance WordPress Search Using Sphinx
Enhance WordPress Search Using Sphinx
 
Tcdnug xamarin
Tcdnug xamarinTcdnug xamarin
Tcdnug xamarin
 
The Social Challenge of 1.5°C Webinar: Karen O'Brien
The Social Challenge of 1.5°C Webinar: Karen O'BrienThe Social Challenge of 1.5°C Webinar: Karen O'Brien
The Social Challenge of 1.5°C Webinar: Karen O'Brien
 
Power electronics projects
Power electronics projectsPower electronics projects
Power electronics projects
 
Mechanical projects
Mechanical projectsMechanical projects
Mechanical projects
 
Xamarin Mobile March 2014
Xamarin Mobile March 2014Xamarin Mobile March 2014
Xamarin Mobile March 2014
 
Hari kantin sekolah
Hari kantin sekolahHari kantin sekolah
Hari kantin sekolah
 
Port folio 20121005
Port folio 20121005Port folio 20121005
Port folio 20121005
 
deepak gorad Final csr
deepak gorad Final csrdeepak gorad Final csr
deepak gorad Final csr
 
2012 Media Highlights
2012 Media Highlights2012 Media Highlights
2012 Media Highlights
 
2 power and hydrogen generation figures
2 power and hydrogen generation figures2 power and hydrogen generation figures
2 power and hydrogen generation figures
 
Leigh lillis resume 7 2016
Leigh lillis resume 7 2016Leigh lillis resume 7 2016
Leigh lillis resume 7 2016
 

Semelhante a MongoDB Live Hacking

Building a Scalable Distributed Stats Infrastructure with Storm and KairosDB
Building a Scalable Distributed Stats Infrastructure with Storm and KairosDBBuilding a Scalable Distributed Stats Infrastructure with Storm and KairosDB
Building a Scalable Distributed Stats Infrastructure with Storm and KairosDBCody Ray
 
MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012Steven Francia
 
2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongoMichael Bright
 
Using MongoDB and Python
Using MongoDB and PythonUsing MongoDB and Python
Using MongoDB and PythonMike Bright
 
MongoDB Days Silicon Valley: MongoDB and the Hadoop Connector
MongoDB Days Silicon Valley: MongoDB and the Hadoop ConnectorMongoDB Days Silicon Valley: MongoDB and the Hadoop Connector
MongoDB Days Silicon Valley: MongoDB and the Hadoop ConnectorMongoDB
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo dbAmit Thakkar
 
MongoDB for Time Series Data Part 3: Sharding
MongoDB for Time Series Data Part 3: ShardingMongoDB for Time Series Data Part 3: Sharding
MongoDB for Time Series Data Part 3: ShardingMongoDB
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance TuningMongoDB
 
MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big DataTakahiro Inoue
 
Advanced Replication
Advanced ReplicationAdvanced Replication
Advanced ReplicationMongoDB
 
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & AggregationWebinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & AggregationMongoDB
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsServer Density
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBMike Dirolf
 
It's 10pm: Do You Know Where Your Writes Are?
It's 10pm: Do You Know Where Your Writes Are?It's 10pm: Do You Know Where Your Writes Are?
It's 10pm: Do You Know Where Your Writes Are?MongoDB
 
SQL? NoSQL? NewSQL?!? What's a Java developer to do? - PhillyETE 2012
SQL? NoSQL? NewSQL?!? What's a Java developer to do? - PhillyETE 2012SQL? NoSQL? NewSQL?!? What's a Java developer to do? - PhillyETE 2012
SQL? NoSQL? NewSQL?!? What's a Java developer to do? - PhillyETE 2012Chris Richardson
 
Unlocking Your Hadoop Data with Apache Spark and CDH5
Unlocking Your Hadoop Data with Apache Spark and CDH5Unlocking Your Hadoop Data with Apache Spark and CDH5
Unlocking Your Hadoop Data with Apache Spark and CDH5SAP Concur
 
Maintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica SetsMaintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica SetsIgor Donchovski
 

Semelhante a MongoDB Live Hacking (20)

Building a Scalable Distributed Stats Infrastructure with Storm and KairosDB
Building a Scalable Distributed Stats Infrastructure with Storm and KairosDBBuilding a Scalable Distributed Stats Infrastructure with Storm and KairosDB
Building a Scalable Distributed Stats Infrastructure with Storm and KairosDB
 
MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012
 
2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo
 
Using MongoDB and Python
Using MongoDB and PythonUsing MongoDB and Python
Using MongoDB and Python
 
MongoDB Days Silicon Valley: MongoDB and the Hadoop Connector
MongoDB Days Silicon Valley: MongoDB and the Hadoop ConnectorMongoDB Days Silicon Valley: MongoDB and the Hadoop Connector
MongoDB Days Silicon Valley: MongoDB and the Hadoop Connector
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo db
 
MongoDB for Time Series Data Part 3: Sharding
MongoDB for Time Series Data Part 3: ShardingMongoDB for Time Series Data Part 3: Sharding
MongoDB for Time Series Data Part 3: Sharding
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 
MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big Data
 
NoSQL Infrastructure
NoSQL InfrastructureNoSQL Infrastructure
NoSQL Infrastructure
 
Advanced Replication
Advanced ReplicationAdvanced Replication
Advanced Replication
 
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & AggregationWebinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
 
Mongodb workshop
Mongodb workshopMongodb workshop
Mongodb workshop
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & Analytics
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
It's 10pm: Do You Know Where Your Writes Are?
It's 10pm: Do You Know Where Your Writes Are?It's 10pm: Do You Know Where Your Writes Are?
It's 10pm: Do You Know Where Your Writes Are?
 
SQL? NoSQL? NewSQL?!? What's a Java developer to do? - PhillyETE 2012
SQL? NoSQL? NewSQL?!? What's a Java developer to do? - PhillyETE 2012SQL? NoSQL? NewSQL?!? What's a Java developer to do? - PhillyETE 2012
SQL? NoSQL? NewSQL?!? What's a Java developer to do? - PhillyETE 2012
 
Unlocking Your Hadoop Data with Apache Spark and CDH5
Unlocking Your Hadoop Data with Apache Spark and CDH5Unlocking Your Hadoop Data with Apache Spark and CDH5
Unlocking Your Hadoop Data with Apache Spark and CDH5
 
Maintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica SetsMaintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica Sets
 
CouchDB on Rails
CouchDB on RailsCouchDB on Rails
CouchDB on Rails
 

Mais de Tobias Trelle

TDD mit JUnit und Mockito
TDD mit JUnit und MockitoTDD mit JUnit und Mockito
TDD mit JUnit und MockitoTobias Trelle
 
NoSQL - Einführung in Graphen-Datenbanken mit Neo4j
NoSQL - Einführung in Graphen-Datenbanken mit Neo4jNoSQL - Einführung in Graphen-Datenbanken mit Neo4j
NoSQL - Einführung in Graphen-Datenbanken mit Neo4jTobias Trelle
 
Einführung in NoSQL-Datenbanken
Einführung in NoSQL-DatenbankenEinführung in NoSQL-Datenbanken
Einführung in NoSQL-DatenbankenTobias Trelle
 
MongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwaltenMongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwaltenTobias Trelle
 
Test Automation for NoSQL Databases
Test Automation for NoSQL DatabasesTest Automation for NoSQL Databases
Test Automation for NoSQL DatabasesTobias Trelle
 
Morphia, Spring Data & Co
Morphia, Spring Data & CoMorphia, Spring Data & Co
Morphia, Spring Data & CoTobias Trelle
 
Spring Data, Jongo & Co.
Spring Data, Jongo & Co.Spring Data, Jongo & Co.
Spring Data, Jongo & Co.Tobias Trelle
 
An introduction to MongoDB and Ruby
An introduction to MongoDB and RubyAn introduction to MongoDB and Ruby
An introduction to MongoDB and RubyTobias Trelle
 
OOP 2013: Praktische Einführung in MongoDB
OOP 2013: Praktische Einführung in MongoDBOOP 2013: Praktische Einführung in MongoDB
OOP 2013: Praktische Einführung in MongoDBTobias Trelle
 
MongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDBMongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDBTobias Trelle
 

Mais de Tobias Trelle (11)

TDD mit JUnit und Mockito
TDD mit JUnit und MockitoTDD mit JUnit und Mockito
TDD mit JUnit und Mockito
 
NoSQL - Einführung in Graphen-Datenbanken mit Neo4j
NoSQL - Einführung in Graphen-Datenbanken mit Neo4jNoSQL - Einführung in Graphen-Datenbanken mit Neo4j
NoSQL - Einführung in Graphen-Datenbanken mit Neo4j
 
Einführung in NoSQL-Datenbanken
Einführung in NoSQL-DatenbankenEinführung in NoSQL-Datenbanken
Einführung in NoSQL-Datenbanken
 
MongoDB Einführung
MongoDB EinführungMongoDB Einführung
MongoDB Einführung
 
MongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwaltenMongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwalten
 
Test Automation for NoSQL Databases
Test Automation for NoSQL DatabasesTest Automation for NoSQL Databases
Test Automation for NoSQL Databases
 
Morphia, Spring Data & Co
Morphia, Spring Data & CoMorphia, Spring Data & Co
Morphia, Spring Data & Co
 
Spring Data, Jongo & Co.
Spring Data, Jongo & Co.Spring Data, Jongo & Co.
Spring Data, Jongo & Co.
 
An introduction to MongoDB and Ruby
An introduction to MongoDB and RubyAn introduction to MongoDB and Ruby
An introduction to MongoDB and Ruby
 
OOP 2013: Praktische Einführung in MongoDB
OOP 2013: Praktische Einführung in MongoDBOOP 2013: Praktische Einführung in MongoDB
OOP 2013: Praktische Einführung in MongoDB
 
MongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDBMongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDB
 

Último

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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 Takeoffsammart93
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Último (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

MongoDB Live Hacking

  • 1. MongoDB Live Coding Session tobias.trelle@codecentric.de @tobiastrelle codecentric AG
  • 2. „It‘s not my fault the chapters are short, MongoDB is just easy to learn“ from „The Little MongoDB book“ codecentric AG
  • 3. MongoDB User Groups by codecentric MongoDB User-Gruppe Düsseldorf https://www.xing.com/net/mongodb-dus @MongoDUS Contact: Tobias Trelle MongoDB User-Gruppe Frankfurt/Main https://www.xing.com/net/mongodb-ffm Contact: Uwe Seiler codecentric AG
  • 4. What is MongoDB? Named from „humongous“ = gigantic http://www.mongodb.org NoSQL datastore, Open Source https://github.com/mongodb support from manufacturer 10gen http://www.10gen.com Highly scalable (scale-out) Stores so called „documents“ Supports replication & sharding Map/Reduce Geospatial indexes / queries codecentric AG
  • 5. Basic structure of a MongoDB server Server Database Relational counterpart But … Flexible Table Collection Schema Row Document - Arrays Column Field - recursive codecentric AG
  • 6. What‘s a document? Single record that can be stored in a collection JSON = JavaScript Object Notation (internal representation BSON = Binary JSON) var doc = { title: „MongoDB_Live_Hacking.pptx“, tags: [ „cc“, „mongodb“, „nosql“ ], slides: [ { nr = 1, header = „MongoDB User Groups by codecentric“}, { nr = 2, header = „MongoDB at codedcentric WiKi“}, … ] }; codecentric AG
  • 7. Live Session CRUD operations Queries Geospatial Queries Map/Reduce Replication Sharding Raw Java API & Spring Data API codecentric AG
  • 8. Geospatial Queries Queries based on 2-dimensional coordinates _id: "A", position: [0.001, -0.002] _id: "B", position: [0.75, 0.75] _id: "C", position: [0.5, 0.5] _id: "D", position: [-0.5, -0.5] Queries based on distances & shapes Details: http://blog.codecentric.de/en/2012/02/spring-data-mongodb-geospatial-queries/ codecentric AG
  • 9. Map/Reduce Data processing algorithm based on two phases: map & reduce Code execution co-located with the data Map phase can be run in parallel (on multiple nodes etc.) on huge data sets MongoDB map / reduce: runs on a subset of / all documents of a collection Map / Reduce algorithms are JS functions Output documents of the map function are input to the reduce function Results are documents stored in a target collection codecentric AG
  • 10. Map/Reduce example We want to count occurences of tags assigned to our documents: {name: „Doc 1“, tags: [ „cc“, „mongodb“, „nosql“ ] } {name: „Doc 2“, tags: [ „cc“, „agile“ ] } Map output: {name: „Doc 3“, tags: [ „cc“ ] } key = „cc“, value = {count: 1} key = „mongodb“, value = {count: 1} key = „nosql“, value = {count: 1} Map function: key = „cc“, value = {count: 1} function() { this.tags.forEach( function(tag) { key = „agile“, value = {count: 1} emit( tag, {count: 1} ) key = „cc“, value = {count: 1} }) } Reduce function: Reduce input: function(key, values) { key = „cc“, values = [ {count: 1}, {count: 1}, {count: 1} ] var result = {count: 0}; key = „mongodb“, values = [ {count: 1} ] values.forEach(function(value) { key = „nosql“, values = [ {count: 1} ] result.count += value.count; key = „agile“, values = [ {count: 1} ] }); return result; } codecentric AG
  • 11. MongoDB Replication A cluster is called „replica set“ Uses Master/Slave replication Writes from clients go to the master only If the master goes down, the slaves elect a new master (n > 2) Replica set w/ n = 3 Slave 1 Client Master Slave 2 codecentric AG
  • 12. MongoDB Sharding Data is distributed over n nodes, each record is persisted only once Data only on the shard nodes Config Server = book keeper, knows where the data is Switch: Gateway for clients Sharding setup Config Server Shard 1 Shard 2 Client Switch codecentric AG
  • 13. MongoDB Sharding in Production Each shard is a replica set + 3 config servers Source: http://www.mongodb.org/display/DOCS/Sharding+Introduction codecentric AG
  • 14. MongoDB Sharding Example: Initial State mongos> sh.status() --- Sharding Status --- sharding version: { "_id" : 1, "version" : 3 } shards: 2 Shards { "_id" : "shard0000", "host" : "tmp-pc:9000" } { "_id" : "shard0001", "host" : "tmp-pc:9001" } databases: { "_id" : "admin", "partitioned" : false, "primary" : "config" } { "_id" : "data", "partitioned" : true, "primary" : "shard0000" } data.foo chunks: shard0000 1 { "age" : { $minKey : 1 } } -->> { "age" : { $maxKey : 1 } } on : shard0000 { "t" : 1000, "i" : 0 } codecentric AG
  • 15. MongoDB Sharding Example: Multiple Chunks mongos> sh.status() --- Sharding Status --- sharding version: { "_id" : 1, "version" : 3 } shards: 2 Shards { "_id" : "shard0000", "host" : "tmp-pc:9000" } { "_id" : "shard0001", "host" : "tmp-pc:9001" } databases: { "_id" : "admin", "partitioned" : false, "primary" : "config" } { "_id" : "data", "partitioned" : true, "primary" : "shard0000" } data.foo chunks: shard0001 4 shard0000 5 Chunks { "age" : { $minKey : 1 } } -->> { "age" : 50 } on : shard0001 { "t" : 2000, "i" : 0 } are equally distributed { "age" : 50 } -->> { "age" : 53 } on : shard0001 { "t" : 3000, "i" : 0 } { "age" : 53 } -->> { "age" : 54 } on : shard0001 { "t" : 4000, "i" : 0 } { "age" : 54 } -->> { "age" : 58 } on : shard0001 { "t" : 5000, "i" : 0 } { "age" : 58 } -->> { "age" : 60 } on : shard0000 { "t" : 5000, "i" : 1 } { "age" : 60 } -->> { "age" : 63 } on : shard0000 { "t" : 1000, "i" : 14 } { "age" : 63 } -->> { "age" : 65 } on : shard0000 { "t" : 1000, "i" : 11 } { "age" : 65 } -->> { "age" : 69 } on : shard0000 { "t" : 1000, "i" : 12 } { "age" : 69 } -->> { "age" : { $maxKey : 1 } } on : shard0000 { "t" : 1000, "i" : 4 } codecentric AG
  • 16. MongoDB API Drivers for many languages (Java, Ruby, PHP, C++, …) Low level Java API: MongoDB Java Driver Spring Data MongoDB: Repository Support + Objekt/Collection Mapping Spring Data CrudRepository PagingAndSortingRepository Spring Data Spring Data Spring Data Spring Data JPA MongoDB Neo4j … JpaRepository MongoRepository GraphRepository MongoTemplate Neo4jTemplate Embedded REST JPA Mongo Java Driver JDBC RDBMS MongoDB Neo4j … codecentric AG
  • 17. QUESTION? Tobias Trelle codecentric AG Merscheider Str. 1 42699 Solingen tel +49 (0) 212.233628.47 fax +49 (0) 212.233628.79 mail Tobias.Trelle@codecentric.de twitter @tobiastrelle www.codecentric.de www.mbg-online.de blog.codecentric.de www.xing.com/net/mongodb-dus codecentric AG 20.08.2012 17