Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
CouchDBA Database for the WebJonathan Weiss
Who am I?Working for Peritor in Berlin, GermanyWritten, maintain, or involved in   Webistrano   Capistrano   SimplyStor...
ScalariumAmazon EC2 Cluster Management   Auto-config   Self-Healing   Auto-Scaling   One-click-deploymentwww.scalarium....
Database RequirementsHigh AvailabilityEasy ReplicationClusteringRobustnessShort Recovery Time                        4
5
CouchDBBuild for the WebScalesReplication built-inEmbracing offlineFlexible schema – document DB                           ...
”CouchDB is built of the Web“               Jacob Kaplan-Moss                                   7
Web TechnologiesHTTP the access protocolJavaScript  the query languageJSON  the storage format                       8
JSON Document {     "_id": "BCCD12CBB",     "_rev": "1-AB764C",     "type": "person",     "name": "Darth Vader",     "age"...
JSON Document {     "_id": "BCCD12CBB",     "_rev": "1-AB764C",     "type": "person",     "name": "Darth Vader",     "age"...
JSON Document {     "_id": "BCCD12CBB",     "_rev": "1-AB764C",     "type": "person",     "name": "Darth Vader",     "age"...
No Tables or Namespaces                          12
No Tables or Namespaces                          13
Manual Namespacing {     "_id": "BCCD12CBB",     "_rev": "1-AB764C",     "type": "person",     "name": "Darth Vader",     ...
Interacting with CouchDB                   JSONHTTP Client              PUT /dbname/ID                               15
Interacting with CouchDB              GET /dbname/IDHTTP Client                   JSON                               16
Interacting with CouchDB              DELETE /dbname/IDHTTP Client                                  17
Views        18
Design Document {     "id": "_design/hats”,     "_rev": "431212AB4”,     "language": "javascript”,     "views": {       "a...
Design Document {                                               Document ID     "id": "_design/hats”,                     ...
Design Document {     "id": "_design/hats”,     "_rev": "431212AB4”,     "language": "javascript”,     "views": {       "a...
Design Document {     "id": "_design/hats”,     "_rev": "431212AB4”,     "language": "javascript”,     "views": {       "a...
Mapfunction(doc) {    if (doc.headware) {      for (var hat in doc.headware) {        emit(hat, 1);      }    }}          ...
Map                                  Passed every                               document in the DBfunction(doc) {    if (d...
Mapfunction(doc) {    if (doc.headware) {                                        Inspects      for (var hat in doc.headwar...
Mapfunction(doc) {    if (doc.headware) {      for (var hat in doc.headware) {        emit(hat, 1);      }    }           ...
Reduce function(keys, values, rereduce) {     return sum(values); }                                      27
Reduce                                     Passed map result                                  (or partial reduce result) f...
Reduce function(keys, values, rereduce) {     return sum(values); }           Aggregates     (count, sum, average, …)     ...
Example Map ResultMap functions are similar to SQL indices                ID               KEY         VALUE         51ABF...
Query a view        GET /dbname/_design/hats/_view/allHTTP Client              {"total_rows":348,"offset":0,"rows”:[      ...
Query a view       GET /dbname/_design/hats/_view/all?        include_docs=trueHTTP Client                                ...
View QueryFilter by   key=ABC123   startkey=123 & endkey=9   limit=100   descending=true   group=true   reduce=true ...
SQL vs. JavaScript                     Vs.                           34
Using Couch from PHPSeveral options available   PHPillow:    http://arbitracker.org/phpillow.html (LGPL 3)   PHP Object_...
36
37
38
39
SimplyStoredCouchDB convenience Layer for Ruby   Models & Associations   Validations   Callbacks               BSD-lice...
Many moreOr just build your own using HTTP!                                     41
Database RequirementsHigh AvailabilityEasy ReplicationClusteringRobustnessShort Recovery Time                        42
Replication   B-TreeXXXXX              Photo by Mathias Meyer                                       43
B-TreeAppend onlyConcurrency (MVCC)Crash resistantHot backupsCompaction                     44
Replication              45
CouchDB Replication                      POST /_replicate                      POST /_replicateEventually consistent & con...
Load Balancing                             Replication HTTP Client     HTTP Load                 Balancer                 ...
Caching HTTP Client   HTTP Cache               Varnish               Apache               …                            48
Multi-Master               49
BigCouch  Clustered CouchDB: Many CouchDBs appear as one  Modeled after Amazon Dynamo  Scalability like Cassandra or Ri...
Q – No. of partitionsBigCouchN – No. of replicasR – Read quorumW – Write quorum                        51
VariousCouchAppsValidationsFiltered replicationChanges feedList functionsFutonGeoFulltext-Search with embedded LuceneDiffe...
Q&APeritor GmbHBlücherstr. 22, Hof III Aufgang 610961 BerlinTel.: +49 (0)30 69 20 09 84 0Fax: +49 (0)30 69 20 09 84 9Inter...
Nächste SlideShare
Wird geladen in …5
×

NoSQL - An introduction to CouchDB

3.559 Aufrufe

Veröffentlicht am

Introduction to CouchDB presented by Jonathan Weiss at BarCampRuhr4

  • DOWNLOAD FULL BOOKS, INTO AVAILABLE Format, ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE Format, ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier

NoSQL - An introduction to CouchDB

  1. 1. CouchDBA Database for the WebJonathan Weiss
  2. 2. Who am I?Working for Peritor in Berlin, GermanyWritten, maintain, or involved in   Webistrano   Capistrano   SimplyStored   Happening   The great fire of Londonhttp://github.com/jweiss@jweiss 2
  3. 3. ScalariumAmazon EC2 Cluster Management   Auto-config   Self-Healing   Auto-Scaling   One-click-deploymentwww.scalarium.com 3
  4. 4. Database RequirementsHigh AvailabilityEasy ReplicationClusteringRobustnessShort Recovery Time 4
  5. 5. 5
  6. 6. CouchDBBuild for the WebScalesReplication built-inEmbracing offlineFlexible schema – document DB 6
  7. 7. ”CouchDB is built of the Web“ Jacob Kaplan-Moss 7
  8. 8. Web TechnologiesHTTP the access protocolJavaScript the query languageJSON the storage format 8
  9. 9. JSON Document { "_id": "BCCD12CBB", "_rev": "1-AB764C", "type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true, "weapons": { "right_arm": "light_saber", "left_arm": null } } 9
  10. 10. JSON Document { "_id": "BCCD12CBB", "_rev": "1-AB764C", "type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true, "weapons": { "right_arm": "light_saber", "left_arm": null } } 10
  11. 11. JSON Document { "_id": "BCCD12CBB", "_rev": "1-AB764C", "type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true, "weapons": { "right_arm": "light_saber", "left_arm": null } } 11
  12. 12. No Tables or Namespaces 12
  13. 13. No Tables or Namespaces 13
  14. 14. Manual Namespacing { "_id": "BCCD12CBB", "_rev": "1-AB764C", "type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true, "weapons": { "right_arm": "light_saber", "left_arm": null } } 14
  15. 15. Interacting with CouchDB JSONHTTP Client PUT /dbname/ID 15
  16. 16. Interacting with CouchDB GET /dbname/IDHTTP Client JSON 16
  17. 17. Interacting with CouchDB DELETE /dbname/IDHTTP Client 17
  18. 18. Views 18
  19. 19. Design Document { "id": "_design/hats”, "_rev": "431212AB4”, "language": "javascript”, "views": { "all": { "map": "function(doc){ .... }”, "reduce": "function(doc){ .... }” }, "by_manufacturer": { "map": "function(doc){ .... }”, "reduce": "function(doc){ .... }” } } } 19
  20. 20. Design Document { Document ID "id": "_design/hats”, – "_rev": "431212AB4”, prefixed by “_design/” "language": "javascript”, "views": { "all": { "map": "function(doc){ .... }”, "reduce": "function(doc){ .... }” }, "by_manufacturer": { "map": "function(doc){ .... }”, "reduce": "function(doc){ .... }” } } } 20
  21. 21. Design Document { "id": "_design/hats”, "_rev": "431212AB4”, "language": "javascript”, "views": { "all": { Hash of Views "map": "function(doc){ .... }”, "reduce": "function(doc){ .... }” }, "by_manufacturer": { "map": "function(doc){ .... }”, "reduce": "function(doc){ .... }” } } } 21
  22. 22. Design Document { "id": "_design/hats”, "_rev": "431212AB4”, "language": "javascript”, "views": { "all": { Hash of Views "map": "function(doc){ .... }”, Every view has map & "reduce": "function(doc){ .... }” reduce function }, "by_manufacturer": { "map": "function(doc){ .... }”, "reduce": "function(doc){ .... }” } } } 22
  23. 23. Mapfunction(doc) { if (doc.headware) { for (var hat in doc.headware) { emit(hat, 1); } }} 23
  24. 24. Map Passed every document in the DBfunction(doc) { if (doc.headware) { for (var hat in doc.headware) { emit(hat, 1); } }} 24
  25. 25. Mapfunction(doc) { if (doc.headware) { Inspects for (var hat in doc.headware) { & Decides emit(hat, 1); } }} 25
  26. 26. Mapfunction(doc) { if (doc.headware) { for (var hat in doc.headware) { emit(hat, 1); } } Emits result} for index 26
  27. 27. Reduce function(keys, values, rereduce) { return sum(values); } 27
  28. 28. Reduce Passed map result (or partial reduce result) function(keys, values, rereduce) { return sum(values); } 28
  29. 29. Reduce function(keys, values, rereduce) { return sum(values); } Aggregates (count, sum, average, …) 29
  30. 30. Example Map ResultMap functions are similar to SQL indices ID KEY VALUE 51ABFA211 Cap 1 ABC123456 Cappy 1 BCCD12CBB Helmet 1 BCCD12CBB Sombrero 1Sorted by the keyKey can also be an arrayValue can be complex JSON and/or reference to other document 30
  31. 31. Query a view GET /dbname/_design/hats/_view/allHTTP Client {"total_rows":348,"offset":0,"rows”:[ {"id":"A","key":"A","value":1}, {"id":"B","key":"B","value":1}, ]} 31
  32. 32. Query a view GET /dbname/_design/hats/_view/all? include_docs=trueHTTP Client 32
  33. 33. View QueryFilter by   key=ABC123   startkey=123 & endkey=9   limit=100   descending=true   group=true   reduce=true   Include_docs=true 33
  34. 34. SQL vs. JavaScript Vs. 34
  35. 35. Using Couch from PHPSeveral options available   PHPillow: http://arbitracker.org/phpillow.html (LGPL 3)   PHP Object_Freezer: https://github.com/sebastianbergmann/php-object-freezer/tree (BSD)   PHP On Couch: http://github.com/dready92/PHP-on-Couch/tree/master (GPLv2 or v3)   PHP CouchDB Extension: http://www.topdog.za.net/php_couchdb_extension (PHP License 3.0)   Sag for CouchDB: http://www.saggingcouch.com/ (Apache License 2.0) 35
  36. 36. 36
  37. 37. 37
  38. 38. 38
  39. 39. 39
  40. 40. SimplyStoredCouchDB convenience Layer for Ruby   Models & Associations   Validations   Callbacks BSD-licensed on   Dynamic finder http://github.com/peritor/simply_stored   S3 attachments On top of CouchPotato, CouchRest & RestClient   Paranoid delete   ActiveModel compliant 40
  41. 41. Many moreOr just build your own using HTTP! 41
  42. 42. Database RequirementsHigh AvailabilityEasy ReplicationClusteringRobustnessShort Recovery Time 42
  43. 43. Replication B-TreeXXXXX Photo by Mathias Meyer 43
  44. 44. B-TreeAppend onlyConcurrency (MVCC)Crash resistantHot backupsCompaction 44
  45. 45. Replication 45
  46. 46. CouchDB Replication POST /_replicate POST /_replicateEventually consistent & conflict resolution 46
  47. 47. Load Balancing Replication HTTP Client HTTP Load Balancer 47
  48. 48. Caching HTTP Client HTTP Cache Varnish Apache … 48
  49. 49. Multi-Master 49
  50. 50. BigCouch  Clustered CouchDB: Many CouchDBs appear as one  Modeled after Amazon Dynamo  Scalability like Cassandra or Riak  github.com/cloudant/bigcouch 50
  51. 51. Q – No. of partitionsBigCouchN – No. of replicasR – Read quorumW – Write quorum 51
  52. 52. VariousCouchAppsValidationsFiltered replicationChanges feedList functionsFutonGeoFulltext-Search with embedded LuceneDifferent experimental View-Server 52
  53. 53. Q&APeritor GmbHBlücherstr. 22, Hof III Aufgang 610961 BerlinTel.: +49 (0)30 69 20 09 84 0Fax: +49 (0)30 69 20 09 84 9Internet: www.peritor.comE-Mail: info@peritor.com© Peritor GmbH - Alle Rechte vorbehalten

×