SlideShare a Scribd company logo
Relax!
                             Sebastian Cohnen
                              @tisba / tisba.de


Mittwoch, 16. November 11
About Me

                • Freier Entwickler
                ❤ Ruby/Rails & node.js
                ❤ Performance & Scalability Engineering
                ❤ Distributed Load Testing
                ❤ CouchDB, Redis & Riak
                und ebenfalls interessiert an Erlang, AMQP, ...



Mittwoch, 16. November 11
Users of Couchdb

                            BBC

                            meebo

                            UbuntuOne

                            ...

                            adcloud




Mittwoch, 16. November 11
CouchDB: Basics


                            Schema-frei

                            Dokumenten-orientiert

                            Key/Value-Speicher

                            fehlertolerant & robust




Mittwoch, 16. November 11
Key Features

                            HTTP + JSON

                            Multi-Master Replikation

                            AP aus CAP

                            Append-only

                            inkrementelle, materialisierte Views (map/reduce)




Mittwoch, 16. November 11
HTTP & JSON




Mittwoch, 16. November 11
Admin Interface




Mittwoch, 16. November 11
Create A Database

                 $ curl -w%{http_code} -X PUT http://127.0.0.1:5984/test_db ↵
                 {"ok":true}
                 201


                 $ $ curl -w%{http_code} -X GET http://127.0.0.1:5984/test_db
                 ↵
                 {"db_name":"test_db","doc_count":0,"doc_del_count":0,
                 "update_seq":1,"purge_seq":0, "compact_running":false,
                 "disk_size":16473, "instance_start_time":
                 "1253091887127542","disk_format_version":4}
                 200




                                           *   $ alias curl='curl -w%{http_code} -X'

Mittwoch, 16. November 11
create A Document
                 $ curl POST -d '{"hello":"world"}' http://127.0.0.1:5984/
                 test_db ↵
                 {"ok":true,"id":"67729d5013cf3f8858eb29cb17e5a723","rev":"1-1
                 5f65339921e497348be384867bb940f"}
                 201




                                       read
                 $ curl GET http://127.0.0.1:5984/test_db/
                 67729d5013cf3f8858eb29cb17e5a723 ↵
                 {"_id":"67729d5013cf3f8858eb29cb17e5a723","_rev":"1-15f653399
                 21e497348be384867bb940f","hello":"world"}
                 200




Mittwoch, 16. November 11
update
                 $ curl PUT -d 
                 '{"_rev":"1-15f65339921e497348be384867bb940f",
                 "hello":"world","message":"about to show CRUD in couch"}'
                 http://127.0.0.1:5984/test_db/ 
                 2f41f56816191b94ecbd127151faa242 ↵
                 {"ok":true,"id":"2f41f56816191b94ecbd127151faa242","rev":"2-2
                 873c60120aa6dbe2204cd2c1a0e8722"}
                 201


                 $ curl GET http://127.0.0.1:5984/test_db/ 
                 2f41f56816191b94ecbd127151faa242 ↵
                 {"_id":"2f41f56816191b94ecbd127151faa242","_rev":"2-2873c6012
                 0aa6dbe2204cd2c1a0e8722","hello":"world","message":"about to
                 show CRUD in couch"}
                 200




Mittwoch, 16. November 11
delete
                 $ curl DELETE http://127.0.0.1:5984/test_db/ 
                 67729d5013cf3f8858eb29cb17e5a723? 
                 rev=1-15f65339921e497348be384867bb940f ↵
                 {"ok":true,"id":"67729d5013cf3f8858eb29cb17e5a723","rev":"2-2
                 d715caed35974bb33de24d1d6c95779"}
                 200


                 $ curl GET http://127.0.0.1:5984/test_db/ 
                 67729d5013cf3f8858eb29cb17e5a723 ↵
                 {"error":"not_found","reason":"deleted"}
                 404




Mittwoch, 16. November 11
CouchApps

                            Dokumente können Attachments haben

                            CouchDB als HTTP Server

                            HTML+CSS+JS ausgeliefert von CouchDB greift via
                            HTTP auf CouchDB als Datenbank zu

                            Beispiel: Kabul War Diary
                            http://upondata.com:5984/afgwar/_design/afgwardiary/
                            index.html



Mittwoch, 16. November 11
Replikation




Mittwoch, 16. November 11
Replikation
                            Replikation läuft via HTTP

                            asynchron

                            inkrementell (online-offline)

                            automatische Konfliktlösung

                            Multi-Version Concurrency Control (MVCC)

                            Multi-Master als default

                            filterbar


Mittwoch, 16. November 11
Map/Reduce Views




Mittwoch, 16. November 11
Accessing Data

                            direkter Zugriff via http://server/DATABASE/DOC-ID

                            materialisierte Views

                               bestehen aus einer map-Phase

                               und einer optionalen reduce-Phase

                            show & list: (Dokument) Transformationen

                            filters, externals, ...



Mittwoch, 16. November 11
Views

                            sortiert, inkrementell, effizienter Zugriff via B-Trees

                            build-in Viewserver:

                               JavaScript (Spidermonkey)

                               Erlang

                            3rd Party Viewserver in Ruby, Python, Java, Perl, ...




Mittwoch, 16. November 11
map/reduce

                            map: Eine Funktion, welche key/value Paare in einen
                            Index schreibt

                            Beispiel Tag-Cloud:

                 1     function(doc) {
                 2       if (doc.tags) {
                 3         for(var idx in doc.tags) {
                 4             emit(doc.tags[idx], 1);
                 5         }
                 6       }
                 7     }




Mittwoch, 16. November 11
map example

                 {“body”:”[...]”, “tags”:[“erlang”, “couchdb”]}
                 {“body”:”[...]”, “tags”:[“couchdb”, “talk”, “rails”]}


                                                     map-function(doc)


                 {“key”:“couchdb”, “value”:1}
                 {“key”:“couchdb”, “value”:1}
                 {“key”:“erlang”, “value”:1}
                 {“key”:“rails”, “value”:1}
                 {“key”:“talk”, “value”:1}

                * indices are automatically sorted




Mittwoch, 16. November 11
map/reduce


                            reduce wird verwendet, um das Ergebnis der map-
                            Phase zu verarbeiten


                 1     function(keys, values, rereduce) {
                 2       return sum(values);
                 3     }




Mittwoch, 16. November 11
reduce example
                 {“key”:“erlang”: “value”:1}
                 {“key”:“couchdb”: “value”:1}
                 {“key”:“couchdb”: “value”:1}
                 {“key”:“talk”: “value”:1}
                 {“key”:“rails”: “value”:1}



                                   reduce function(...)


                 {"key":"erlang","value":1}
                 {"key":"couchdb","value":2}
                 {"key":"talk","value":1}
                 {"key":"rails","value":1}




Mittwoch, 16. November 11
CouchDB: Pros


                            HTTP (Proxy, Caches, Loadbalancer, ...)

                            HTTP (CouchDB als Webserver, 2-tier Apps!)

                            Replikation

                            Views sind sortiert; effizienter Zugriff auf Ranges




Mittwoch, 16. November 11
Cons


                            Append-only erfordert Compaction

                            Append-only & MVCC/Konfliktlösung führen zu
                            Probleme bei Update-heavy Anwendungen

                            keine verteilte Datenbank (sharding, clustering)




Mittwoch, 16. November 11
Get it!
                            http://couchdb.apache.org/downloads.html

                               brew install couchdb / apt-get install couchdb / ...

                            freies Hosting: www.iriscouch.com

                            BigCouch (cloudant.com / https://github.com/cloudant/bigcouch)

                               dynamo-style CouchDB Cluster

                            Couchbase (www.couchbase.com)

                               Membase+CouchDB


Mittwoch, 16. November 11
Thanks! Q & A?


                                     ?
                                 Sebastian Cohnen
                                      @tisba


Mittwoch, 16. November 11
Understanding
                               reduce
                 1     function(keys, values, rereduce) {}


                            a b c d | e f g h | i j k l | m n
                            1 2 1 3 | 1 2 3 1 | 2 3 3 1 | 1 8
                               7         7    |     9       9
                                  14                    18
                                             32

                  function(     [[“a”,id1],[“b”,id2],[“c”,id3],[“d”,id4]],
                                 [1,         2,       1,        3],
                                false) {...}


                  function(null, [ 7, 7], true) {...}
                  function(null, [ 9, 9], true) {...}
                  function(null, [14,18], true) {...}

Mittwoch, 16. November 11

More Related Content

PDF
ElasticSearch
PDF
Vidoop CouchDB Talk
PDF
Data Processing Inside PostgreSQL
 
PDF
Nodejs - A quick tour (v6)
PDF
Ruby meetup ROM
PDF
Devinsampa nginx-scripting
PDF
Debugging and Testing ES Systems
ODP
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
ElasticSearch
Vidoop CouchDB Talk
Data Processing Inside PostgreSQL
 
Nodejs - A quick tour (v6)
Ruby meetup ROM
Devinsampa nginx-scripting
Debugging and Testing ES Systems
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani

What's hot (20)

PDF
What is nodejs
PDF
Couchdb w Ruby'm
PDF
Lua tech talk
KEY
Node.js - A practical introduction (v2)
PDF
Database schema management in Ruby apps
PDF
Py conkr 20150829_docker-python
PDF
BlockChain implementation by python
PDF
Miscelaneous Debris
PDF
Node.js - A Quick Tour II
PDF
Ansible leveraging 2.0
PDF
No REST for the Wicked: REST and Catalyst
PDF
Challenges when building high profile editorial sites
PDF
Devon 2011-f-4-improve your-javascript
PDF
Developing JavaScript Widgets
PDF
Redis - Usability and Use Cases
PDF
Puppet fundamentals
PDF
Who is afraid of privileged containers ?
KEY
第一回MongoDBソースコードリーディング
PDF
Kicking ass with redis
What is nodejs
Couchdb w Ruby'm
Lua tech talk
Node.js - A practical introduction (v2)
Database schema management in Ruby apps
Py conkr 20150829_docker-python
BlockChain implementation by python
Miscelaneous Debris
Node.js - A Quick Tour II
Ansible leveraging 2.0
No REST for the Wicked: REST and Catalyst
Challenges when building high profile editorial sites
Devon 2011-f-4-improve your-javascript
Developing JavaScript Widgets
Redis - Usability and Use Cases
Puppet fundamentals
Who is afraid of privileged containers ?
第一回MongoDBソースコードリーディング
Kicking ass with redis
Ad

Viewers also liked (6)

PDF
Erlang web framework: Chicago boss
PDF
NoSQL CGN: Riak (01/2012)
PDF
Artist in Transit @RSE11
PDF
Movement, Empathie und die Sehnsucht nach Rhythmus
PDF
Einführung in nosql // ArangoDB mit Symfony 2
PDF
OpenData - Was hat das mit mir zu tun? @RSE13
Erlang web framework: Chicago boss
NoSQL CGN: Riak (01/2012)
Artist in Transit @RSE11
Movement, Empathie und die Sehnsucht nach Rhythmus
Einführung in nosql // ArangoDB mit Symfony 2
OpenData - Was hat das mit mir zu tun? @RSE13
Ad

Similar to NoSQL CGN: CouchDB (11/2011) (20)

PDF
Couchdbkit djangocong-20100425
PDF
Couchdbkit & Dango
PDF
Ruby on CouchDB - SimplyStored and RockingChair
PDF
CouchDB
PDF
GeekCamp SG 2009 - CouchApps with CouchDB
PDF
Mongo db with spring data document
ODP
Intro to CouchDB
PDF
Rooted 2011 nosql security
PDF
Writing CouchDB Views using ClojureScript
PDF
Introduction to CouchDB
PDF
CouchDB Mobile - From Couch to 5K in 1 Hour
PDF
BRAINREPUBLIC - Powered by no-SQL
PDF
Introduction to couchdb
KEY
OSCON 2011 Learning CouchDB
PDF
CouchDB Open Source Bridge
PDF
Couchdb Nosql
PDF
Using NoSQL with Yo' SQL
PDF
CouchDB
PPT
No sql Database
Couchdbkit djangocong-20100425
Couchdbkit & Dango
Ruby on CouchDB - SimplyStored and RockingChair
CouchDB
GeekCamp SG 2009 - CouchApps with CouchDB
Mongo db with spring data document
Intro to CouchDB
Rooted 2011 nosql security
Writing CouchDB Views using ClojureScript
Introduction to CouchDB
CouchDB Mobile - From Couch to 5K in 1 Hour
BRAINREPUBLIC - Powered by no-SQL
Introduction to couchdb
OSCON 2011 Learning CouchDB
CouchDB Open Source Bridge
Couchdb Nosql
Using NoSQL with Yo' SQL
CouchDB
No sql Database

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Tartificialntelligence_presentation.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Hybrid model detection and classification of lung cancer
Building Integrated photovoltaic BIPV_UPV.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Programs and apps: productivity, graphics, security and other tools
MIND Revenue Release Quarter 2 2025 Press Release
OMC Textile Division Presentation 2021.pptx
WOOl fibre morphology and structure.pdf for textiles
Univ-Connecticut-ChatGPT-Presentaion.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Unlocking AI with Model Context Protocol (MCP)
Heart disease approach using modified random forest and particle swarm optimi...
Accuracy of neural networks in brain wave diagnosis of schizophrenia
cloud_computing_Infrastucture_as_cloud_p
Web App vs Mobile App What Should You Build First.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Tartificialntelligence_presentation.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Hybrid model detection and classification of lung cancer

NoSQL CGN: CouchDB (11/2011)

  • 1. Relax! Sebastian Cohnen @tisba / tisba.de Mittwoch, 16. November 11
  • 2. About Me • Freier Entwickler ❤ Ruby/Rails & node.js ❤ Performance & Scalability Engineering ❤ Distributed Load Testing ❤ CouchDB, Redis & Riak und ebenfalls interessiert an Erlang, AMQP, ... Mittwoch, 16. November 11
  • 3. Users of Couchdb BBC meebo UbuntuOne ... adcloud Mittwoch, 16. November 11
  • 4. CouchDB: Basics Schema-frei Dokumenten-orientiert Key/Value-Speicher fehlertolerant & robust Mittwoch, 16. November 11
  • 5. Key Features HTTP + JSON Multi-Master Replikation AP aus CAP Append-only inkrementelle, materialisierte Views (map/reduce) Mittwoch, 16. November 11
  • 6. HTTP & JSON Mittwoch, 16. November 11
  • 8. Create A Database $ curl -w%{http_code} -X PUT http://127.0.0.1:5984/test_db ↵ {"ok":true} 201 $ $ curl -w%{http_code} -X GET http://127.0.0.1:5984/test_db ↵ {"db_name":"test_db","doc_count":0,"doc_del_count":0, "update_seq":1,"purge_seq":0, "compact_running":false, "disk_size":16473, "instance_start_time": "1253091887127542","disk_format_version":4} 200 * $ alias curl='curl -w%{http_code} -X' Mittwoch, 16. November 11
  • 9. create A Document $ curl POST -d '{"hello":"world"}' http://127.0.0.1:5984/ test_db ↵ {"ok":true,"id":"67729d5013cf3f8858eb29cb17e5a723","rev":"1-1 5f65339921e497348be384867bb940f"} 201 read $ curl GET http://127.0.0.1:5984/test_db/ 67729d5013cf3f8858eb29cb17e5a723 ↵ {"_id":"67729d5013cf3f8858eb29cb17e5a723","_rev":"1-15f653399 21e497348be384867bb940f","hello":"world"} 200 Mittwoch, 16. November 11
  • 10. update $ curl PUT -d '{"_rev":"1-15f65339921e497348be384867bb940f", "hello":"world","message":"about to show CRUD in couch"}' http://127.0.0.1:5984/test_db/ 2f41f56816191b94ecbd127151faa242 ↵ {"ok":true,"id":"2f41f56816191b94ecbd127151faa242","rev":"2-2 873c60120aa6dbe2204cd2c1a0e8722"} 201 $ curl GET http://127.0.0.1:5984/test_db/ 2f41f56816191b94ecbd127151faa242 ↵ {"_id":"2f41f56816191b94ecbd127151faa242","_rev":"2-2873c6012 0aa6dbe2204cd2c1a0e8722","hello":"world","message":"about to show CRUD in couch"} 200 Mittwoch, 16. November 11
  • 11. delete $ curl DELETE http://127.0.0.1:5984/test_db/ 67729d5013cf3f8858eb29cb17e5a723? rev=1-15f65339921e497348be384867bb940f ↵ {"ok":true,"id":"67729d5013cf3f8858eb29cb17e5a723","rev":"2-2 d715caed35974bb33de24d1d6c95779"} 200 $ curl GET http://127.0.0.1:5984/test_db/ 67729d5013cf3f8858eb29cb17e5a723 ↵ {"error":"not_found","reason":"deleted"} 404 Mittwoch, 16. November 11
  • 12. CouchApps Dokumente können Attachments haben CouchDB als HTTP Server HTML+CSS+JS ausgeliefert von CouchDB greift via HTTP auf CouchDB als Datenbank zu Beispiel: Kabul War Diary http://upondata.com:5984/afgwar/_design/afgwardiary/ index.html Mittwoch, 16. November 11
  • 14. Replikation Replikation läuft via HTTP asynchron inkrementell (online-offline) automatische Konfliktlösung Multi-Version Concurrency Control (MVCC) Multi-Master als default filterbar Mittwoch, 16. November 11
  • 16. Accessing Data direkter Zugriff via http://server/DATABASE/DOC-ID materialisierte Views bestehen aus einer map-Phase und einer optionalen reduce-Phase show & list: (Dokument) Transformationen filters, externals, ... Mittwoch, 16. November 11
  • 17. Views sortiert, inkrementell, effizienter Zugriff via B-Trees build-in Viewserver: JavaScript (Spidermonkey) Erlang 3rd Party Viewserver in Ruby, Python, Java, Perl, ... Mittwoch, 16. November 11
  • 18. map/reduce map: Eine Funktion, welche key/value Paare in einen Index schreibt Beispiel Tag-Cloud: 1 function(doc) { 2 if (doc.tags) { 3 for(var idx in doc.tags) { 4 emit(doc.tags[idx], 1); 5 } 6 } 7 } Mittwoch, 16. November 11
  • 19. map example {“body”:”[...]”, “tags”:[“erlang”, “couchdb”]} {“body”:”[...]”, “tags”:[“couchdb”, “talk”, “rails”]} map-function(doc) {“key”:“couchdb”, “value”:1} {“key”:“couchdb”, “value”:1} {“key”:“erlang”, “value”:1} {“key”:“rails”, “value”:1} {“key”:“talk”, “value”:1} * indices are automatically sorted Mittwoch, 16. November 11
  • 20. map/reduce reduce wird verwendet, um das Ergebnis der map- Phase zu verarbeiten 1 function(keys, values, rereduce) { 2 return sum(values); 3 } Mittwoch, 16. November 11
  • 21. reduce example {“key”:“erlang”: “value”:1} {“key”:“couchdb”: “value”:1} {“key”:“couchdb”: “value”:1} {“key”:“talk”: “value”:1} {“key”:“rails”: “value”:1} reduce function(...) {"key":"erlang","value":1} {"key":"couchdb","value":2} {"key":"talk","value":1} {"key":"rails","value":1} Mittwoch, 16. November 11
  • 22. CouchDB: Pros HTTP (Proxy, Caches, Loadbalancer, ...) HTTP (CouchDB als Webserver, 2-tier Apps!) Replikation Views sind sortiert; effizienter Zugriff auf Ranges Mittwoch, 16. November 11
  • 23. Cons Append-only erfordert Compaction Append-only & MVCC/Konfliktlösung führen zu Probleme bei Update-heavy Anwendungen keine verteilte Datenbank (sharding, clustering) Mittwoch, 16. November 11
  • 24. Get it! http://couchdb.apache.org/downloads.html brew install couchdb / apt-get install couchdb / ... freies Hosting: www.iriscouch.com BigCouch (cloudant.com / https://github.com/cloudant/bigcouch) dynamo-style CouchDB Cluster Couchbase (www.couchbase.com) Membase+CouchDB Mittwoch, 16. November 11
  • 25. Thanks! Q & A? ? Sebastian Cohnen @tisba Mittwoch, 16. November 11
  • 26. Understanding reduce 1 function(keys, values, rereduce) {} a b c d | e f g h | i j k l | m n 1 2 1 3 | 1 2 3 1 | 2 3 3 1 | 1 8 7 7 | 9 9 14 18 32 function( [[“a”,id1],[“b”,id2],[“c”,id3],[“d”,id4]], [1, 2, 1, 3], false) {...} function(null, [ 7, 7], true) {...} function(null, [ 9, 9], true) {...} function(null, [14,18], true) {...} Mittwoch, 16. November 11