SlideShare ist ein Scribd-Unternehmen logo
1 von 45
BATTLE OF THE
 NO-SQL STARS
CouchDB, MongoDB, Amazon SDB, RavenDB
WHO IS THIS GUY?

Jesse Wolgamott

(Nobody, Really)

Team Merrica Lead Developer

ChaiOne, Houston

http://jessewolgamott.com
OUR STARS


CouchDB: Apache Project, Circa 2007‘ish

MongoDB: 10Gen, Circa 2009

SimpleDB: Amazon, Circa 2007

RavenDB: Ayenda, Circa 2010
EVIL
NUGGET
EVIL
  NUGGET
Document Databases share an
  internal structure similar
       (inspired?) by:
       Lotus Notes.
         (shudder)
BATTLE
    PLAN
    Languages and API
        Versioning
Internal Queries and Inserts
        Intangibles
THE COOL KID
APIS

CouchDB: Erlang, REST
API

MongoDB: C++, Language
Driver

RavenDB: .NET, REST API

SimpleDB: Erlang, Name/
Value Store
API: COUCHDB
POST /somedatabase/ HTTP/1.0
Content-Length: 245
Content-Type: application/json

{
    "Subject":"I like Plankton",
    "Author":"Rusty",
    "PostedDate":"2006-08-15T17:30:12-04:00",
    "Tags":["plankton", "baseball", "decisions"],
    "Body":"I decided today that I don't like baseball. I like plankton."
}
-----------------
GET /somedatabase/some_doc_id HTTP/1.0
-------------------
HTTP/1.1 200 OK
Date: Thu, 17 Aug 2006 05:39:28 +0000GMT
Content-Type: application/json
Connection: close

{
 "_id":"some_doc_id",
 "_rev":"946B7D1C",
 "Subject":"I like Plankton",
 "Author":"Rusty",
 "PostedDate":"2006-08-15T17:30:12Z-04:00",
 "Tags":["plankton", "baseball", "decisions"],
 "Body":"I decided today that I don't like baseball. I like plankton."
}
API: COUCHPOTATO
class User
  include CouchPotato::Persistence

  property :age, :type => Fixnum
  property :receive_newsletter, :type => :boolean
end

CouchPotato.database.save_document User.new
API: MONGODB
   Mongoid                                MongoMapper

class Person                           class Person


 include Mongoid::Document              include MongoMapper::Document

 field :name                            key :name, String, :required=>true

 embeds_many :phones                    many :phones

 references_many :addresses             has_many :addresses

end                                    end

Person.create {:name=>”Darth Vader”}   Person.create {:name=>”Darth Vader”}
MM V GOID
Mongoid uses ActiveModel   Mongoid uses ARel, MM:
(Rails3).                  custom DSL

MongoMapper is more like   Mongoid has Master/Slave
Rails 2 with Validatable
                           MM is more familiar for
MongoMapper has better     Active Record
relational association
support
API: RAVENDB
PUT http://localhost:8080/docs/bobs_address
 {
   FirstName: 'Bob',
   LastName: 'Smith',
   Address: '5 Elm St'
 }
---------------
GET http://localhost:8080/docs/bobs_address
---------------
HTTP/1.1 200 OK

{
    "FirstName": "Bob",
    "LastName": "Smith",
    "Address": "5 Elm St."
}


var companies = session.Query<Company>("CompaniesByRegion")
       .Where(x => x.Region == "Asia")
       .Take(5);
API: SIMPLEDB
 Amazon’s Restful... This is rest?

 Answer: No (IMHO). And returns XML
https://sdb.amazonaws.com/?Action=PutAttributes
&DomainName=MyDomain
&ItemName=Item123
&Attribute.1.Name=Color&Attribute.1.Value=Blue
&Attribute.2.Name=Size&Attribute.2.Value=Med
&Attribute.3.Name=Price&Attribute.3.Value=0014.99
&AWSAccessKeyId=<valid_access_key>
&Version=2007-11-07
&Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQE=
&SignatureVersion=2
&SignatureMethod=HmacSHA256
&Timestamp=2007-06-25T15%3A01%3A28-07%3A00
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
VERSIONING
 Do we rea!y have it?
VERSIONING

CouchDB has Multi Versioning Concurrency Control

  Compaction removes old revs, only the latest rev is represented in view queries, and only the latest revision is
  replicated.


  you can only depending on having a single version of the document available.


  Especially in Multi-Master



Mongoid::Versioning (has_many versions)

RavenDB - Versioning Built In
VERSIONING
CouchDB and                                 Mongoid
Mongomapper                                 class Person
                                             include Mongoid::Document
   Roll your Own
                                             include Mongoid::Versioning

   Using many versions as embedded           # keep at most 5 versions of a record
   documents                                 max_versions 5
                                            end
RavenDB
<appSettings>
 <add key="Raven/Versioning/MaxRevisions"
  value="50"/>
 <add key="Raven/Versioning/Exclude"
  value="Comments;LogEntries;"/>
</appSettings>
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
QUERIES
Gimme Gimme Gimme
QUERIES: COUCH
    Map/Reduce .. Design Documents
        Cool Part: Fast!
        The NotHot: Pre-declaring all your views

{
    "_id":"_design/company",
    "_rev":"12345",
    "language": "javascript",
    "views":
    {
      "all": {
         "map": "function(doc) { if (doc.Type == 'customer') emit(null, doc) }"
      },
      "by_lastname": {
         "map": "function(doc) { if (doc.Type == 'customer') emit(doc.LastName, doc) }"
      },
      "total_purchases": {
         "map": "function(doc) { if (doc.Type == 'purchase') emit(doc.Customer, doc.Amount) }",
         "reduce": "function(keys, values) { return sum(values) }"
      }
    }
}
QUERY: MONGODB


Dynamic Querying

Map-Reduce (BUT: non-concurrent)

MongoMapper Example

  Event.where(:school_id=>school.id).published.future.sort(:start.desc).limit(20).all
QUERY: SIMPLEDB

No sorting options

Obvious comparison operators (=, !=,<=, etc.)

RightAWS Interface

require 'right_aws'


sdb = RightAws::SdbInterface.new(aws_access_key, aws_secret_access_key)


sdb.query("picture", "['submitdate' <= '2900'] intersection ['status' = 'approved'] sort 'submitdate'")


#parse XML returned
QUERY: RAVENDB

MapReduce Indexes

Raven process them in the background, executing the
queries against the stored documents and persisting the
results to a Lucene index

Raven executes your indexes in the background, and the
results are written to disk.

Indexes are written in LINQ
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
INSERTING
  Here take this
INSERTS: COUCH


Couch DB PUT API is cool.

BUT

Recalculates the map-reduce on the insertion

Slows down over time
INSERTS: MONGO


Updates in Place

FAST, BUT

In Air Collisions

Power Turns Off before disk write
INSERTS: BENCHMARK
 Bulk Insertion Benchmark
 Data: http://www.snailinaturtleneck.com/blog/2009/06/29/couchdb-vs-mongodb-benchmark/


 y-axis: seconds

                                                     MongoDB              CouchDB
40

30

20

10

0
     1     10      50     100      500    1000     2500    7500 10000 25000 100000
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
EXTRAS
MongoDBs - Best Ruby         CouchDB: Multi-Multi
Integration                  Master (Success!)

SimpleDB: Easy Scalability   CouchDB: Offline
                             Replication
RavenDB: Windows
(Downer)                     CouchDB and MongoDB:
                             Free Levels on Heroku
RavenDB: Commercial          (Crazy Success)
License for non-Open
Source (Downer-er)
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
SCOREBOARD

        API   Versions Queries   Inserts   Extras

Couch

Mongo

SDB

Raven
LITTLE BIT OF CODE


MLB 2000-2009 Game Data used in Demo

The information used here was obtained free of charge from and is copyrighted by Retrosheet.
Interested parties may contact Retrosheet at "www.retrosheet.org".



Load Time Experience - 24000‘ish Games

                                                      Load Time in Seconds
                   Mongo                                        77.6 seconds
                   Couch                                       355.1 seconds

Weitere ähnliche Inhalte

Was ist angesagt?

Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
Michael Pirnat
 
Flickr Architecture Presentation
Flickr Architecture PresentationFlickr Architecture Presentation
Flickr Architecture Presentation
eraz
 

Was ist angesagt? (20)

Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
Going to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific LanguagesGoing to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific Languages
 
You suck at Memory Analysis
You suck at Memory AnalysisYou suck at Memory Analysis
You suck at Memory Analysis
 
PyGrunn 2017 - Django Performance Unchained - slides
PyGrunn 2017 - Django Performance Unchained - slidesPyGrunn 2017 - Django Performance Unchained - slides
PyGrunn 2017 - Django Performance Unchained - slides
 
Ror Seminar With agilebd.org on 23 Jan09
Ror Seminar With agilebd.org on 23 Jan09Ror Seminar With agilebd.org on 23 Jan09
Ror Seminar With agilebd.org on 23 Jan09
 
O que há de novo no Rails 3
O que há de novo no Rails 3O que há de novo no Rails 3
O que há de novo no Rails 3
 
Games for the Masses (Jax)
Games for the Masses (Jax)Games for the Masses (Jax)
Games for the Masses (Jax)
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
Compiled Websites with Plone, Django, Xapian and SSI
Compiled Websites with Plone, Django, Xapian and SSICompiled Websites with Plone, Django, Xapian and SSI
Compiled Websites with Plone, Django, Xapian and SSI
 
Intro to PSGI and Plack
Intro to PSGI and PlackIntro to PSGI and Plack
Intro to PSGI and Plack
 
IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ ...
IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ ...IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ ...
IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ ...
 
A python web service
A python web serviceA python web service
A python web service
 
Security Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSecurity Goodness with Ruby on Rails
Security Goodness with Ruby on Rails
 
Debugging on rails
Debugging on railsDebugging on rails
Debugging on rails
 
Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
 
4Developers 2018: Structured logging (Bartek Szurgot)
4Developers 2018: Structured logging (Bartek Szurgot)4Developers 2018: Structured logging (Bartek Szurgot)
4Developers 2018: Structured logging (Bartek Szurgot)
 
Flickr Architecture Presentation
Flickr Architecture PresentationFlickr Architecture Presentation
Flickr Architecture Presentation
 
Introducing RaveJS: Spring Boot concepts for JavaScript applications
Introducing RaveJS: Spring Boot concepts for JavaScript applicationsIntroducing RaveJS: Spring Boot concepts for JavaScript applications
Introducing RaveJS: Spring Boot concepts for JavaScript applications
 
AMD - Why, What and How
AMD - Why, What and HowAMD - Why, What and How
AMD - Why, What and How
 

Ähnlich wie Battle of NoSQL stars: Amazon's SDB vs MongoDB vs CouchDB vs RavenDB

MongoDB and Ruby on Rails
MongoDB and Ruby on RailsMongoDB and Ruby on Rails
MongoDB and Ruby on Rails
rfischer20
 
Socket applications
Socket applicationsSocket applications
Socket applications
João Moura
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
intelliyole
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 

Ähnlich wie Battle of NoSQL stars: Amazon's SDB vs MongoDB vs CouchDB vs RavenDB (20)

Ibm_interconnect_restapi_workshop
Ibm_interconnect_restapi_workshopIbm_interconnect_restapi_workshop
Ibm_interconnect_restapi_workshop
 
Seattle StrongLoop Node.js Workshop
Seattle StrongLoop Node.js WorkshopSeattle StrongLoop Node.js Workshop
Seattle StrongLoop Node.js Workshop
 
Continuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWSContinuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWS
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 
FOXX - a Javascript application framework on top of ArangoDB
FOXX - a Javascript application framework on top of ArangoDBFOXX - a Javascript application framework on top of ArangoDB
FOXX - a Javascript application framework on top of ArangoDB
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 
MongoDB and Ruby on Rails
MongoDB and Ruby on RailsMongoDB and Ruby on Rails
MongoDB and Ruby on Rails
 
Socket applications
Socket applicationsSocket applications
Socket applications
 
Play framework
Play frameworkPlay framework
Play framework
 
FP - Découverte de Play Framework Scala
FP - Découverte de Play Framework ScalaFP - Découverte de Play Framework Scala
FP - Découverte de Play Framework Scala
 
Rapid, Scalable Web Development with MongoDB, Ming, and Python
Rapid, Scalable Web Development with MongoDB, Ming, and PythonRapid, Scalable Web Development with MongoDB, Ming, and Python
Rapid, Scalable Web Development with MongoDB, Ming, and Python
 
mongodb-introduction
mongodb-introductionmongodb-introduction
mongodb-introduction
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic Framework
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 

Kürzlich hochgeladen

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
Enterprise Knowledge
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
[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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
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)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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
 

Battle of NoSQL stars: Amazon's SDB vs MongoDB vs CouchDB vs RavenDB

  • 1. BATTLE OF THE NO-SQL STARS CouchDB, MongoDB, Amazon SDB, RavenDB
  • 2. WHO IS THIS GUY? Jesse Wolgamott (Nobody, Really) Team Merrica Lead Developer ChaiOne, Houston http://jessewolgamott.com
  • 3. OUR STARS CouchDB: Apache Project, Circa 2007‘ish MongoDB: 10Gen, Circa 2009 SimpleDB: Amazon, Circa 2007 RavenDB: Ayenda, Circa 2010
  • 5. EVIL NUGGET Document Databases share an internal structure similar (inspired?) by: Lotus Notes. (shudder)
  • 6. BATTLE PLAN Languages and API Versioning Internal Queries and Inserts Intangibles
  • 8. APIS CouchDB: Erlang, REST API MongoDB: C++, Language Driver RavenDB: .NET, REST API SimpleDB: Erlang, Name/ Value Store
  • 9. API: COUCHDB POST /somedatabase/ HTTP/1.0 Content-Length: 245 Content-Type: application/json { "Subject":"I like Plankton", "Author":"Rusty", "PostedDate":"2006-08-15T17:30:12-04:00", "Tags":["plankton", "baseball", "decisions"], "Body":"I decided today that I don't like baseball. I like plankton." } ----------------- GET /somedatabase/some_doc_id HTTP/1.0 ------------------- HTTP/1.1 200 OK Date: Thu, 17 Aug 2006 05:39:28 +0000GMT Content-Type: application/json Connection: close { "_id":"some_doc_id", "_rev":"946B7D1C", "Subject":"I like Plankton", "Author":"Rusty", "PostedDate":"2006-08-15T17:30:12Z-04:00", "Tags":["plankton", "baseball", "decisions"], "Body":"I decided today that I don't like baseball. I like plankton." }
  • 10. API: COUCHPOTATO class User include CouchPotato::Persistence property :age, :type => Fixnum property :receive_newsletter, :type => :boolean end CouchPotato.database.save_document User.new
  • 11. API: MONGODB Mongoid MongoMapper class Person class Person include Mongoid::Document include MongoMapper::Document field :name key :name, String, :required=>true embeds_many :phones many :phones references_many :addresses has_many :addresses end end Person.create {:name=>”Darth Vader”} Person.create {:name=>”Darth Vader”}
  • 12. MM V GOID Mongoid uses ActiveModel Mongoid uses ARel, MM: (Rails3). custom DSL MongoMapper is more like Mongoid has Master/Slave Rails 2 with Validatable MM is more familiar for MongoMapper has better Active Record relational association support
  • 13. API: RAVENDB PUT http://localhost:8080/docs/bobs_address { FirstName: 'Bob', LastName: 'Smith', Address: '5 Elm St' } --------------- GET http://localhost:8080/docs/bobs_address --------------- HTTP/1.1 200 OK { "FirstName": "Bob", "LastName": "Smith", "Address": "5 Elm St." } var companies = session.Query<Company>("CompaniesByRegion") .Where(x => x.Region == "Asia") .Take(5);
  • 14. API: SIMPLEDB Amazon’s Restful... This is rest? Answer: No (IMHO). And returns XML https://sdb.amazonaws.com/?Action=PutAttributes &DomainName=MyDomain &ItemName=Item123 &Attribute.1.Name=Color&Attribute.1.Value=Blue &Attribute.2.Name=Size&Attribute.2.Value=Med &Attribute.3.Name=Price&Attribute.3.Value=0014.99 &AWSAccessKeyId=<valid_access_key> &Version=2007-11-07 &Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQE= &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2007-06-25T15%3A01%3A28-07%3A00
  • 15. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 16. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 17. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 18. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 19. VERSIONING Do we rea!y have it?
  • 20. VERSIONING CouchDB has Multi Versioning Concurrency Control Compaction removes old revs, only the latest rev is represented in view queries, and only the latest revision is replicated. you can only depending on having a single version of the document available. Especially in Multi-Master Mongoid::Versioning (has_many versions) RavenDB - Versioning Built In
  • 21. VERSIONING CouchDB and Mongoid Mongomapper class Person include Mongoid::Document Roll your Own include Mongoid::Versioning Using many versions as embedded # keep at most 5 versions of a record documents max_versions 5 end RavenDB <appSettings> <add key="Raven/Versioning/MaxRevisions" value="50"/> <add key="Raven/Versioning/Exclude" value="Comments;LogEntries;"/> </appSettings>
  • 22. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 23. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 25. QUERIES: COUCH Map/Reduce .. Design Documents Cool Part: Fast! The NotHot: Pre-declaring all your views { "_id":"_design/company", "_rev":"12345", "language": "javascript", "views": { "all": { "map": "function(doc) { if (doc.Type == 'customer') emit(null, doc) }" }, "by_lastname": { "map": "function(doc) { if (doc.Type == 'customer') emit(doc.LastName, doc) }" }, "total_purchases": { "map": "function(doc) { if (doc.Type == 'purchase') emit(doc.Customer, doc.Amount) }", "reduce": "function(keys, values) { return sum(values) }" } } }
  • 26. QUERY: MONGODB Dynamic Querying Map-Reduce (BUT: non-concurrent) MongoMapper Example Event.where(:school_id=>school.id).published.future.sort(:start.desc).limit(20).all
  • 27. QUERY: SIMPLEDB No sorting options Obvious comparison operators (=, !=,<=, etc.) RightAWS Interface require 'right_aws' sdb = RightAws::SdbInterface.new(aws_access_key, aws_secret_access_key) sdb.query("picture", "['submitdate' <= '2900'] intersection ['status' = 'approved'] sort 'submitdate'") #parse XML returned
  • 28. QUERY: RAVENDB MapReduce Indexes Raven process them in the background, executing the queries against the stored documents and persisting the results to a Lucene index Raven executes your indexes in the background, and the results are written to disk. Indexes are written in LINQ
  • 29. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 30. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 31. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 32. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 33. INSERTING Here take this
  • 34. INSERTS: COUCH Couch DB PUT API is cool. BUT Recalculates the map-reduce on the insertion Slows down over time
  • 35. INSERTS: MONGO Updates in Place FAST, BUT In Air Collisions Power Turns Off before disk write
  • 36. INSERTS: BENCHMARK Bulk Insertion Benchmark Data: http://www.snailinaturtleneck.com/blog/2009/06/29/couchdb-vs-mongodb-benchmark/ y-axis: seconds MongoDB CouchDB 40 30 20 10 0 1 10 50 100 500 1000 2500 7500 10000 25000 100000
  • 37. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 38. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 39. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 40. EXTRAS MongoDBs - Best Ruby CouchDB: Multi-Multi Integration Master (Success!) SimpleDB: Easy Scalability CouchDB: Offline Replication RavenDB: Windows (Downer) CouchDB and MongoDB: Free Levels on Heroku RavenDB: Commercial (Crazy Success) License for non-Open Source (Downer-er)
  • 41. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 42. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 43. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 44. SCOREBOARD API Versions Queries Inserts Extras Couch Mongo SDB Raven
  • 45. LITTLE BIT OF CODE MLB 2000-2009 Game Data used in Demo The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org". Load Time Experience - 24000‘ish Games Load Time in Seconds Mongo 77.6 seconds Couch 355.1 seconds

Hinweis der Redaktion