SlideShare une entreprise Scribd logo
1  sur  77
Télécharger pour lire hors ligne
JAOO October 5th, 2009




   Apache
CouchDB
      Jason Davies
About Jason
•   Cambridge University (2002-2005)
•   Director, Jason Davies Ltd (2005-present)
•   Web Developer: Python, Django,
    JavaScript, jQuery, Erlang, &c.
•   Apache CouchDB committer (2009)
CouchDB
  from
3,333km
CouchDB Features
•   “Cluster of Unreliable Commodity Hardware”
•   Schema-free (JSON)
•   Document-oriented, distributed database
•   RESTful HTTP API
•   JavaScript-powered Map/Reduce
•   N-Master Replication
Schema-Free (JSON)
•

                           Features
•   Document Oriented,
    Not Relational

•   Highly Concurrent

•   RESTful HTTP API

•   JavaScript-Powered
    Map/Reduce

•   N-Master Replication

•   Robust Storage
Schema-Free (JSON)
•

                           Features
•   Document Oriented,
    Not Relational

•   Highly Concurrent

•   RESTful HTTP API

•   JavaScript-Powered
    Map/Reduce

•   N-Master Replication

•   Robust Storage
http://www.flickr.com/photos/stilleben2001/223243329/




Documents
Schema-Free ( JSON)
{
    "_id": "BCCD12CBB",
    "_rev": "AB764C",

    "type": "person",
    "name": "Darth Vader",
    "age": 63,
    "headware":
      ["Helmet", "Sombrero"],
    "dark_side": true
}
Schema-Free ( JSON)
{
    "_id": "BCCD12CBB",
    "_rev": "AB764C",

    "type": "person",
    "name": "Darth Vader",
    "age": 63,
    "headware":
      ["Helmet", "Sombrero"],
    "dark_side": true
}
Schema-Free ( JSON)
{
    "_id": "BCCD12CBB",
    "_rev": "AB764C",

    "type": "person",
    "name": "Darth Vader",
    "age": 63,
    "headware":
      ["Helmet", "Sombrero"],
    "dark_side": true
}
Schema-Free ( JSON)
{
    "_id": "BCCD12CBB",
    "_rev": "AB764C",

    "type": "person",
    "name": "Darth Vader",
    "age": 63,
    "headware":
      ["Helmet", "Sombrero"],
    "dark_side": true
}
Schema-Free (JSON)
•

                           Features
•   Document-Oriented,
    Not Relational

•   Highly Concurrent

•   RESTful HTTP API

•   JavaScript-Powered
    Map/Reduce

•   N-Master Replication

•   Robust Storage
Document-Oriented
                                   Not Relational

•   Documents in the Real World™
    •   Bills, letters, tax forms…
    •   Same type != same structure
    •   Can be out of date (so what?)
    •   No references
Document-Oriented
                                   Not Relational
•   Documents in the Real World™
        Bills, letters, tax forms…
        Natural Data
    •


    •   Same type != same structure
    •
           Behaviour
        Can be out of date  (so what?)

    •   No references
Schema-Free (JSON)
•

                           Features
•   Document-Oriented,
    Not Relational

•   Highly Concurrent

•   RESTful HTTP API

•   JavaScript-Powered
    Map/Reduce

•   N-Master Replication

•   Robust Storage
Highly Concurrent
                             Erlang FTW


•   Functional languages highly appropriate
    for parallellism
•   Lightweight “processes” and message-
    passing; “shared-nothing”
•   Easy to create fault-tolerant systems
MVCC
•   Multiversion Concurrency Control
•   Reads: lock-free; never block
    •   Potential for massive horizontal scaling
•   Writes: all-or-nothing
    •   Success
    •   Fail: conflict error, fetch and try again
Schema-Free (JSON)
•

                           Features
•   Document-Oriented,
    Not Relational

•   Highly Concurrent

•   RESTful HTTP API

•   JavaScript-Powered
    Map/Reduce

•   N-Master Replication

•   Robust Storage
ful
                              CRUD
•   Create
    HTTP PUT /db/mydocid
•   Read
    HTTP GET /db/mydocid
•   Update
    HTTP PUT /db/mydocid
•   Delete
    HTTP DELETE /db/mydocid
ful
                                Example
couch = CouchRest.database!("http://
127.0.0.1:5984/tweets")


tweets_url = "http://twitter.com/statuses/
user_timeline.json"


tweets = http.get(tweets_url)
couch.bulk_save(tweets)
Cacheability
•   Both documents and views return ETags
•   Clients send If-None-Match
    •   CouchDB responds with 304 Not
        Modified and bypasses potentially
        expensive lookup
•   Can use Varnish/Squid as caching proxy
•   Proxy- friendly
Schema-Free (JSON)
•

                           Features
•   Document-Oriented,
    Not Relational

•   Highly Concurrent

•   RESTful HTTP API

•   JavaScript-Powered
    Map/Reduce

•   N-Master Replication

•   Robust Storage
JavaScript-Powered
           Map/Reduce
•   Map functions extract data from your
    documents
•   Reduce functions aggregate intermediate
    values
•   The kicker: Incremental B-tree storage
http://horicky.blogspot.com/2008/10/couchdb-implementation.html
Map/Reduce Views
     Docs
                                 Map
{"user" : "Chris",
                      function(doc) {                        {"key": "Alice", "value": 5}
     "points" : 3 }
                        if (doc.user && doc.points) {          {"key": "Bob", "value": 7}
    {"user": "Joe",
                           emit(doc.user, doc.points);      {"key": "Chris", "value": 3}
   "points" : 10 }
                        }                                     {"key": "Joe", "value": 10}
 {"user": "Alice",
                      }                                      {"key": "Mary", "value": 9}
     "points" : 5 }
 {"user": "Mary",
      "points" : 9}
   {"user": "Bob",
                               Reduce
       "points": 7}    function(keys, values, rereduce) {     Alice ... Chris: 15
                         return sum(values);                       Everyone: 34
                       }
Map/Reduce Views
     Docs
                                 Map
{"user" : "Chris",
                      function(doc) {                        {"key": "Alice", "value": 5}
     "points" : 3 }
                        if (doc.user && doc.points) {          {"key": "Bob", "value": 7}
    {"user": "Joe",
                           emit(doc.user, doc.points);      {"key": "Chris", "value": 3}
   "points" : 10 }
                        }                                     {"key": "Joe", "value": 10}
 {"user": "Alice",
                      }                                      {"key": "Mary", "value": 9}
     "points" : 5 }
 {"user": "Mary",
      "points" : 9}
   {"user": "Bob",
                               Reduce
       "points": 7}    function(keys, values, rereduce) {          Alice … Chris: 15
                         return sum(values);                            Everyone: 34
                       }
Map/Reduce Views
      Docs
                                 Map
{"user" : "Chris",
                      function(doc) {                        {"key": "Alice", "value": 5}
     "points" : 3 }
                        if (doc.user && doc.points) {          {"key": "Bob", "value": 7}
    {"user": "Joe",
                           emit(doc.user, doc.points);      {"key": "Chris", "value": 3}
   "points" : 10 }
                        }                                     {"key": "Joe", "value": 10}
 {"user": "Alice",
                      }                                      {"key": "Mary", "value": 9}
     "points" : 5 }
 {"user": "Mary",
      "points" : 9}
   {"user": "Bob",
                               Reduce
       "points": 7}    function(keys, values, rereduce) {          Alice … Chris: 15
                         return sum(values);                            Everyone: 34
                       }
Render Views as HTML
lists/index.js            /drl/_list/sofa/index/recent-posts?descending=true&limit=8
Server-Side JavaScript
•   _show for transforming documents
•   _list for transforming views
•   _update for transforming PUTs/POSTs
•   Code-sharing between client and server
•   Easy deployment
Schema-Free (JSON)
•

                           Features
•   Document-Oriented,
    Not Relational

•   Highly Concurrent

•   RESTful HTTP API

•   JavaScript-Powered
    Map/Reduce

•   N-Master Replication

•   Robust Storage
Replication
•   Incremental
•   Near-real-time
    •   Clustered mirrors
•   Scheduled
•   Ad-hoc
“Ground Computing”
                              @jhuggins




         http://www.flickr.com/photos/mcpig/872293700/
http://www.flickr.com/photos/hercwad/2290378571/
Latency Sucks
Stuart Langridge - Canonical




!   !
Con icts
Con ict resolution by
     example


 A               B


 ❦
Con ict resolution by
     example


 A               B


 ❦
Con ict resolution by
     example


 A               B


 ❦              ✿
                ❦
Con ict resolution by
     example


 A               B


                ✿
Con ict resolution by
     example


 A               B


                     ✿
Schema-Free (JSON)
•

                           Features
•   Document-Oriented,
    Not Relational

•   Highly Concurrent

•   RESTful HTTP API

•   JavaScript-Powered
    Map/Reduce

•   N-Master Replication

•   Robust Storage
Robust Storage

Append-Only
File Structure

Designed to
Crash

Instant-On
Robust
No Silver Bullet!
•   Read-optimised; not so much for writes
    •   Use ?batch=ok for “don’t care” logging
•   Views must be specified beforehand
    •   Relational databases are better at highly
        dynamic queries
    •   But: use externals e.g. Lucene, SQLite
Experiments!




http://www.flickr.com/photos/seanstayte/378461237/
`couchapp`
• Scripts written in Python to make
  developing pure CouchDB applications
  easier
• sudo easy_install couchapp
• couchapp generate relax && cd relax
• couchapp push http://127.0.0.1:5984/mydb
Directory Structure
Resulting Design Doc
_list
• Arbitrary JS transformation for views
• http://127.0.0.1:5984/mydb/_design/app/
  _list/myview?startkey=...&endkey=...
• JSON -> HTML, JSON -> XML, ...
• E4X nice for XML generation
• Iteratively call getRow() and use send(...)
_show

• Arbitrary transformation for documents
• http://127.0.0.1:5984/mydb/_design/app/
  _show/mydoc
• function (doc, req) { return “foo”; }
JavaScript Templating
•   EmbeddedJS (EJS)

    •   <% /* execute arbitrary JS */ %>

    •   <%= /* execute and include result */ %>

    •   new EJS({ text: mytemplate }).render(doc);

•   John Resig’s Micro-Templating

    •   new template(mytemplate)(doc);

    •   Doesn’t preserve whitespace or LaTeX
        backslashes
Push Helper Macros
• Simple macros to facilitate code re-use
• Insert code directly
 • // !code path/to/code.js
• Encode file as JSON: path/to/test.html
 • // !json path.to.test
 • // !json _attachments/test.html
Secure Cookie Authentication
• Reasonable performance/simplicity of
  JavaScript implementation
• Mutual authentication
• Resistance to off-line dictionary attacks
  based on passive eavesdropping
• Passwords stored in a form that is not
  plaintext-equivalent
• Limited resistance to replay attacks
Tamper-Proof Cookies


Timestamp + signature => limited forward-security
        (outside of timestamp window)
Secure Remote Password Protocol (SRP)

• Zero-Knowledge Password Proof
• Simple to implement in Erlang using BigInt
  and crypto libraries
• JavaScript too slow: over 5s for 1024 bits
• Vulnerable to active injection attacks
• There are simpler protocols that can be
  used to give equivalent security
• Just add SSL for protection from active
  attacks (or lobby for TLS-SRP/J-PAKE!)
@couchdbinaction




http://books.couchdb.org/relax
Thank you
for listening!
www.jasondavies.com

   @jasondavies

Contenu connexe

Tendances

CouchDB at New York PHP
CouchDB at New York PHPCouchDB at New York PHP
CouchDB at New York PHPBradley Holt
 
Entity Relationships in a Document Database at CouchConf Boston
Entity Relationships in a Document Database at CouchConf BostonEntity Relationships in a Document Database at CouchConf Boston
Entity Relationships in a Document Database at CouchConf BostonBradley Holt
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation FrameworkTyler Brock
 
Aggregation Framework
Aggregation FrameworkAggregation Framework
Aggregation FrameworkMongoDB
 
Aggregation in MongoDB
Aggregation in MongoDBAggregation in MongoDB
Aggregation in MongoDBKishor Parkhe
 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross LawleyOSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross LawleyNETWAYS
 
Mongo db washington dc 2014
Mongo db washington dc 2014Mongo db washington dc 2014
Mongo db washington dc 2014ikanow
 
Building web applications with mongo db presentation
Building web applications with mongo db presentationBuilding web applications with mongo db presentation
Building web applications with mongo db presentationMurat Çakal
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data ModelingDATAVERSITY
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation FrameworkCaserta
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRailsMike Dirolf
 
Learn Learn how to build your mobile back-end with MongoDB
Learn Learn how to build your mobile back-end with MongoDBLearn Learn how to build your mobile back-end with MongoDB
Learn Learn how to build your mobile back-end with MongoDBMarakana Inc.
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichNorberto Leite
 
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDBMongoDB
 
MongoDB, E-commerce and Transactions
MongoDB, E-commerce and TransactionsMongoDB, E-commerce and Transactions
MongoDB, E-commerce and TransactionsSteven Francia
 
Tearing the Sofa Apart: CouchDB and CouchApps from a Beginner's Perspective
Tearing the Sofa Apart: CouchDB and CouchApps from a Beginner's PerspectiveTearing the Sofa Apart: CouchDB and CouchApps from a Beginner's Perspective
Tearing the Sofa Apart: CouchDB and CouchApps from a Beginner's PerspectiveSeh Hui Leong
 

Tendances (20)

CouchDB at New York PHP
CouchDB at New York PHPCouchDB at New York PHP
CouchDB at New York PHP
 
Entity Relationships in a Document Database at CouchConf Boston
Entity Relationships in a Document Database at CouchConf BostonEntity Relationships in a Document Database at CouchConf Boston
Entity Relationships in a Document Database at CouchConf Boston
 
JSON-LD and MongoDB
JSON-LD and MongoDBJSON-LD and MongoDB
JSON-LD and MongoDB
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation Framework
 
Aggregation Framework
Aggregation FrameworkAggregation Framework
Aggregation Framework
 
Aggregation in MongoDB
Aggregation in MongoDBAggregation in MongoDB
Aggregation in MongoDB
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross LawleyOSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
 
Mongo db washington dc 2014
Mongo db washington dc 2014Mongo db washington dc 2014
Mongo db washington dc 2014
 
Building web applications with mongo db presentation
Building web applications with mongo db presentationBuilding web applications with mongo db presentation
Building web applications with mongo db presentation
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation Framework
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRails
 
Learn Learn how to build your mobile back-end with MongoDB
Learn Learn how to build your mobile back-end with MongoDBLearn Learn how to build your mobile back-end with MongoDB
Learn Learn how to build your mobile back-end with MongoDB
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days Munich
 
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 
MongoDB, E-commerce and Transactions
MongoDB, E-commerce and TransactionsMongoDB, E-commerce and Transactions
MongoDB, E-commerce and Transactions
 
MongoDB
MongoDBMongoDB
MongoDB
 
Json tutorial, a beguiner guide
Json tutorial, a beguiner guideJson tutorial, a beguiner guide
Json tutorial, a beguiner guide
 
Tearing the Sofa Apart: CouchDB and CouchApps from a Beginner's Perspective
Tearing the Sofa Apart: CouchDB and CouchApps from a Beginner's PerspectiveTearing the Sofa Apart: CouchDB and CouchApps from a Beginner's Perspective
Tearing the Sofa Apart: CouchDB and CouchApps from a Beginner's Perspective
 

Similaire à CouchDB at JAOO Århus 2009

Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL Josh Price
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responsesdarrelmiller71
 
MongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewMongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewAntonio Pintus
 
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...MongoDB
 
Differential Sync and JSON Patch @ SpringOne2GX 2014
Differential Sync and JSON Patch @ SpringOne2GX 2014Differential Sync and JSON Patch @ SpringOne2GX 2014
Differential Sync and JSON Patch @ SpringOne2GX 2014Brian Cavalier
 
Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB MongoDB
 
N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0Keshav Murthy
 
Couchdb: No SQL? No driver? No problem
Couchdb: No SQL? No driver? No problemCouchdb: No SQL? No driver? No problem
Couchdb: No SQL? No driver? No problemdelagoya
 
Mongodb intro
Mongodb introMongodb intro
Mongodb introchristkv
 
ElasticSearch AJUG 2013
ElasticSearch AJUG 2013ElasticSearch AJUG 2013
ElasticSearch AJUG 2013Roy Russo
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDBMongoDB
 
d3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlind3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in BerlinToshiaki Katayama
 
Your Database Cannot Do this (well)
Your Database Cannot Do this (well)Your Database Cannot Do this (well)
Your Database Cannot Do this (well)javier ramirez
 
Elastic search and Symfony3 - A practical approach
Elastic search and Symfony3 - A practical approachElastic search and Symfony3 - A practical approach
Elastic search and Symfony3 - A practical approachSymfonyMu
 
Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)Sean Cribbs
 

Similaire à CouchDB at JAOO Århus 2009 (20)

Couch db
Couch dbCouch db
Couch db
 
Vidoop CouchDB Talk
Vidoop CouchDB TalkVidoop CouchDB Talk
Vidoop CouchDB Talk
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL
 
No sql Database
No sql DatabaseNo sql Database
No sql Database
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responses
 
MongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewMongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overview
 
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
 
Differential Sync and JSON Patch @ SpringOne2GX 2014
Differential Sync and JSON Patch @ SpringOne2GX 2014Differential Sync and JSON Patch @ SpringOne2GX 2014
Differential Sync and JSON Patch @ SpringOne2GX 2014
 
MongoDB at GUL
MongoDB at GULMongoDB at GUL
MongoDB at GUL
 
Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB
 
N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0
 
Couchdb: No SQL? No driver? No problem
Couchdb: No SQL? No driver? No problemCouchdb: No SQL? No driver? No problem
Couchdb: No SQL? No driver? No problem
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
ElasticSearch AJUG 2013
ElasticSearch AJUG 2013ElasticSearch AJUG 2013
ElasticSearch AJUG 2013
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDB
 
d3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlind3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlin
 
Your Database Cannot Do this (well)
Your Database Cannot Do this (well)Your Database Cannot Do this (well)
Your Database Cannot Do this (well)
 
Elastic search and Symfony3 - A practical approach
Elastic search and Symfony3 - A practical approachElastic search and Symfony3 - A practical approach
Elastic search and Symfony3 - A practical approach
 
Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)
 
Einführung in MongoDB
Einführung in MongoDBEinführung in MongoDB
Einführung in MongoDB
 

Dernier

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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
[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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
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 MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Dernier (20)

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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
[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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

CouchDB at JAOO Århus 2009

  • 1. JAOO October 5th, 2009 Apache CouchDB Jason Davies
  • 2. About Jason • Cambridge University (2002-2005) • Director, Jason Davies Ltd (2005-present) • Web Developer: Python, Django, JavaScript, jQuery, Erlang, &c. • Apache CouchDB committer (2009)
  • 4. CouchDB Features • “Cluster of Unreliable Commodity Hardware” • Schema-free (JSON) • Document-oriented, distributed database • RESTful HTTP API • JavaScript-powered Map/Reduce • N-Master Replication
  • 5.
  • 6.
  • 7. Schema-Free (JSON) • Features • Document Oriented, Not Relational • Highly Concurrent • RESTful HTTP API • JavaScript-Powered Map/Reduce • N-Master Replication • Robust Storage
  • 8. Schema-Free (JSON) • Features • Document Oriented, Not Relational • Highly Concurrent • RESTful HTTP API • JavaScript-Powered Map/Reduce • N-Master Replication • Robust Storage
  • 10. Schema-Free ( JSON) { "_id": "BCCD12CBB", "_rev": "AB764C", "type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true }
  • 11. Schema-Free ( JSON) { "_id": "BCCD12CBB", "_rev": "AB764C", "type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true }
  • 12. Schema-Free ( JSON) { "_id": "BCCD12CBB", "_rev": "AB764C", "type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true }
  • 13. Schema-Free ( JSON) { "_id": "BCCD12CBB", "_rev": "AB764C", "type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true }
  • 14. Schema-Free (JSON) • Features • Document-Oriented, Not Relational • Highly Concurrent • RESTful HTTP API • JavaScript-Powered Map/Reduce • N-Master Replication • Robust Storage
  • 15. Document-Oriented Not Relational • Documents in the Real World™ • Bills, letters, tax forms… • Same type != same structure • Can be out of date (so what?) • No references
  • 16. Document-Oriented Not Relational • Documents in the Real World™ Bills, letters, tax forms… Natural Data • • Same type != same structure • Behaviour Can be out of date (so what?) • No references
  • 17. Schema-Free (JSON) • Features • Document-Oriented, Not Relational • Highly Concurrent • RESTful HTTP API • JavaScript-Powered Map/Reduce • N-Master Replication • Robust Storage
  • 18.
  • 19.
  • 20. Highly Concurrent Erlang FTW • Functional languages highly appropriate for parallellism • Lightweight “processes” and message- passing; “shared-nothing” • Easy to create fault-tolerant systems
  • 21. MVCC • Multiversion Concurrency Control • Reads: lock-free; never block • Potential for massive horizontal scaling • Writes: all-or-nothing • Success • Fail: conflict error, fetch and try again
  • 22. Schema-Free (JSON) • Features • Document-Oriented, Not Relational • Highly Concurrent • RESTful HTTP API • JavaScript-Powered Map/Reduce • N-Master Replication • Robust Storage
  • 23. ful CRUD • Create HTTP PUT /db/mydocid • Read HTTP GET /db/mydocid • Update HTTP PUT /db/mydocid • Delete HTTP DELETE /db/mydocid
  • 24. ful Example couch = CouchRest.database!("http:// 127.0.0.1:5984/tweets") tweets_url = "http://twitter.com/statuses/ user_timeline.json" tweets = http.get(tweets_url) couch.bulk_save(tweets)
  • 25. Cacheability • Both documents and views return ETags • Clients send If-None-Match • CouchDB responds with 304 Not Modified and bypasses potentially expensive lookup • Can use Varnish/Squid as caching proxy • Proxy- friendly
  • 26. Schema-Free (JSON) • Features • Document-Oriented, Not Relational • Highly Concurrent • RESTful HTTP API • JavaScript-Powered Map/Reduce • N-Master Replication • Robust Storage
  • 27. JavaScript-Powered Map/Reduce • Map functions extract data from your documents • Reduce functions aggregate intermediate values • The kicker: Incremental B-tree storage
  • 29. Map/Reduce Views Docs Map {"user" : "Chris", function(doc) { {"key": "Alice", "value": 5} "points" : 3 } if (doc.user && doc.points) { {"key": "Bob", "value": 7} {"user": "Joe", emit(doc.user, doc.points); {"key": "Chris", "value": 3} "points" : 10 } } {"key": "Joe", "value": 10} {"user": "Alice", } {"key": "Mary", "value": 9} "points" : 5 } {"user": "Mary", "points" : 9} {"user": "Bob", Reduce "points": 7} function(keys, values, rereduce) { Alice ... Chris: 15 return sum(values); Everyone: 34 }
  • 30. Map/Reduce Views Docs Map {"user" : "Chris", function(doc) { {"key": "Alice", "value": 5} "points" : 3 } if (doc.user && doc.points) { {"key": "Bob", "value": 7} {"user": "Joe", emit(doc.user, doc.points); {"key": "Chris", "value": 3} "points" : 10 } } {"key": "Joe", "value": 10} {"user": "Alice", } {"key": "Mary", "value": 9} "points" : 5 } {"user": "Mary", "points" : 9} {"user": "Bob", Reduce "points": 7} function(keys, values, rereduce) { Alice … Chris: 15 return sum(values); Everyone: 34 }
  • 31. Map/Reduce Views Docs Map {"user" : "Chris", function(doc) { {"key": "Alice", "value": 5} "points" : 3 } if (doc.user && doc.points) { {"key": "Bob", "value": 7} {"user": "Joe", emit(doc.user, doc.points); {"key": "Chris", "value": 3} "points" : 10 } } {"key": "Joe", "value": 10} {"user": "Alice", } {"key": "Mary", "value": 9} "points" : 5 } {"user": "Mary", "points" : 9} {"user": "Bob", Reduce "points": 7} function(keys, values, rereduce) { Alice … Chris: 15 return sum(values); Everyone: 34 }
  • 32. Render Views as HTML lists/index.js /drl/_list/sofa/index/recent-posts?descending=true&limit=8
  • 33. Server-Side JavaScript • _show for transforming documents • _list for transforming views • _update for transforming PUTs/POSTs • Code-sharing between client and server • Easy deployment
  • 34. Schema-Free (JSON) • Features • Document-Oriented, Not Relational • Highly Concurrent • RESTful HTTP API • JavaScript-Powered Map/Reduce • N-Master Replication • Robust Storage
  • 35. Replication • Incremental • Near-real-time • Clustered mirrors • Scheduled • Ad-hoc
  • 36. “Ground Computing” @jhuggins http://www.flickr.com/photos/mcpig/872293700/
  • 39. Stuart Langridge - Canonical ! !
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 50. Con ict resolution by example A B ❦
  • 51. Con ict resolution by example A B ❦
  • 52. Con ict resolution by example A B ❦ ✿ ❦
  • 53. Con ict resolution by example A B ✿
  • 54. Con ict resolution by example A B ✿
  • 55. Schema-Free (JSON) • Features • Document-Oriented, Not Relational • Highly Concurrent • RESTful HTTP API • JavaScript-Powered Map/Reduce • N-Master Replication • Robust Storage
  • 58. No Silver Bullet! • Read-optimised; not so much for writes • Use ?batch=ok for “don’t care” logging • Views must be specified beforehand • Relational databases are better at highly dynamic queries • But: use externals e.g. Lucene, SQLite
  • 60. `couchapp` • Scripts written in Python to make developing pure CouchDB applications easier • sudo easy_install couchapp • couchapp generate relax && cd relax • couchapp push http://127.0.0.1:5984/mydb
  • 63. _list • Arbitrary JS transformation for views • http://127.0.0.1:5984/mydb/_design/app/ _list/myview?startkey=...&endkey=... • JSON -> HTML, JSON -> XML, ... • E4X nice for XML generation • Iteratively call getRow() and use send(...)
  • 64. _show • Arbitrary transformation for documents • http://127.0.0.1:5984/mydb/_design/app/ _show/mydoc • function (doc, req) { return “foo”; }
  • 65. JavaScript Templating • EmbeddedJS (EJS) • <% /* execute arbitrary JS */ %> • <%= /* execute and include result */ %> • new EJS({ text: mytemplate }).render(doc); • John Resig’s Micro-Templating • new template(mytemplate)(doc); • Doesn’t preserve whitespace or LaTeX backslashes
  • 66. Push Helper Macros • Simple macros to facilitate code re-use • Insert code directly • // !code path/to/code.js • Encode file as JSON: path/to/test.html • // !json path.to.test • // !json _attachments/test.html
  • 67. Secure Cookie Authentication • Reasonable performance/simplicity of JavaScript implementation • Mutual authentication • Resistance to off-line dictionary attacks based on passive eavesdropping • Passwords stored in a form that is not plaintext-equivalent • Limited resistance to replay attacks
  • 68.
  • 69. Tamper-Proof Cookies Timestamp + signature => limited forward-security (outside of timestamp window)
  • 70. Secure Remote Password Protocol (SRP) • Zero-Knowledge Password Proof • Simple to implement in Erlang using BigInt and crypto libraries • JavaScript too slow: over 5s for 1024 bits • Vulnerable to active injection attacks • There are simpler protocols that can be used to give equivalent security • Just add SSL for protection from active attacks (or lobby for TLS-SRP/J-PAKE!)
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.