SlideShare a Scribd company logo
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

More Related Content

What's hot

Introduction to Restkit
Introduction to RestkitIntroduction to Restkit
Introduction to Restkit
petertmarks
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
MongoDB
 
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-refactor
Xiaojun REN
 
Getting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSGetting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJS
MongoDB
 
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 MongoDB
James 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 MongoDB
Scott Hernandez
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile services
Aymeric 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 Database
Mike 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 MongoDB
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
MongoDB
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMS
uzquiano
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
Tobias 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 Vaswani
vvaswani
 
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
 
Return of c++
Return of c++Return of c++
Return of c++
Yongwei Wu
 

What's hot (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++
 

Viewers also liked

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
Leigh Ellen Lillis
 
Meatco AGM 2012 - CEO Presentation
Meatco AGM 2012 - CEO PresentationMeatco AGM 2012 - CEO Presentation
Meatco AGM 2012 - CEO Presentation
meatconamibia
 
Windows7
Windows7Windows7
Ppt newton's law
Ppt newton's lawPpt newton's law
Ppt newton's law
mamardc
 
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
Iowa CarSales
 
Wireless projects
Wireless projectsWireless projects
Wireless projects
Senthil Kumar
 
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-phpapp01
Deepak R Gorad
 
Enhance WordPress Search Using Sphinx
Enhance WordPress Search Using SphinxEnhance WordPress Search Using Sphinx
Enhance WordPress Search Using Sphinx
Roshan Bhattarai
 
Tcdnug xamarin
Tcdnug xamarinTcdnug xamarin
Tcdnug xamarin
Joe Koletar
 
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
tewksjj
 
Power electronics projects
Power electronics projectsPower electronics projects
Power electronics projects
Senthil Kumar
 
Mechanical projects
Mechanical projectsMechanical projects
Mechanical projects
Senthil Kumar
 
Xamarin Mobile March 2014
Xamarin Mobile March 2014Xamarin Mobile March 2014
Xamarin Mobile March 2014
Joe Koletar
 
Hari kantin sekolah
Hari kantin sekolahHari kantin sekolah
Hari kantin sekolah
Nurul Umiera Sazali
 
Port folio 20121005
Port folio 20121005Port folio 20121005
Port folio 20121005
Thành Mắm
 
deepak gorad Final csr
deepak gorad Final csrdeepak gorad Final csr
deepak gorad Final csr
Deepak R Gorad
 
2012 Media Highlights
2012 Media Highlights2012 Media Highlights
2012 Media Highlights
meatconamibia
 
2 power and hydrogen generation figures
2 power and hydrogen generation figures2 power and hydrogen generation figures
2 power and hydrogen generation figures
novi5036
 
Leigh lillis resume 7 2016
Leigh lillis resume 7 2016Leigh lillis resume 7 2016
Leigh lillis resume 7 2016
Leigh Ellen Lillis
 

Viewers also liked (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
 

Similar to 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 KairosDB
Cody 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 2012
Steven Francia
 
Using MongoDB and Python
Using MongoDB and PythonUsing MongoDB and Python
Using MongoDB and Python
Mike Bright
 
2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo
Michael 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 Connector
MongoDB
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo db
Amit 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: Sharding
MongoDB
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
MongoDB
 
MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big Data
Takahiro Inoue
 
NoSQL Infrastructure
NoSQL InfrastructureNoSQL Infrastructure
NoSQL Infrastructure
Server Density
 
Advanced Replication
Advanced ReplicationAdvanced Replication
Advanced Replication
MongoDB
 
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
 
Mongodb workshop
Mongodb workshopMongodb workshop
Mongodb workshop
Harun Yardımcı
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & Analytics
Server Density
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Mike 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 2012
Chris 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 CDH5
SAP Concur
 
Maintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica SetsMaintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica Sets
Igor Donchovski
 
CouchDB on Rails
CouchDB on RailsCouchDB on Rails
CouchDB on Rails
Jonathan Weiss
 

Similar to 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
 
Using MongoDB and Python
Using MongoDB and PythonUsing MongoDB and Python
Using MongoDB and Python
 
2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo
 
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
 

More from Tobias Trelle

TDD mit JUnit und Mockito
TDD mit JUnit und MockitoTDD mit JUnit und Mockito
TDD mit JUnit und Mockito
Tobias 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 Neo4j
Tobias Trelle
 
Einführung in NoSQL-Datenbanken
Einführung in NoSQL-DatenbankenEinführung in NoSQL-Datenbanken
Einführung in NoSQL-Datenbanken
Tobias Trelle
 
MongoDB Einführung
MongoDB EinführungMongoDB Einführung
MongoDB Einführung
Tobias 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 Databases
Tobias 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 Ruby
Tobias 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 MongoDB
Tobias Trelle
 
MongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDBMongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDB
Tobias Trelle
 

More from 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
 

Recently uploaded

5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 

Recently uploaded (20)

5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 

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