SlideShare ist ein Scribd-Unternehmen logo
1 von 77
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Kürzlich hochgeladen (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

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.