Introduction to REST & CouchDB
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Introduction to REST & CouchDB

on

  • 11,647 views

A presentation introducing REST and CouchDB given at the "Web Enigineering" course at Ulm University, 2011/01/28.

A presentation introducing REST and CouchDB given at the "Web Enigineering" course at Ulm University, 2011/01/28.

Statistics

Views

Total Views
11,647
Views on SlideShare
11,400
Embed Views
247

Actions

Likes
11
Downloads
218
Comments
0

8 Embeds 247

http://www.benjamin-erb.de 216
http://benjamin-erb.de 24
https://twitter.com 2
http://paper.li 1
http://www.netvibes.com 1
http://translate.googleusercontent.com 1
http://10.150.200.76 1
http://www.slashdocs.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduction to REST & CouchDB Presentation Transcript

  • 1. Introduction to REST & CouchDBBenjamin Erb | 28.01.2011 | Universität Ulm Web Engineering WS10/11
  • 2. Slide 2 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Introduction Benjamin Erb http://twitter.com/b_erb http://github.com/berb http://www.benjamin-erb.de student of computer sciene & media informatics Ulm University, Germany
  • 3. Part I: REST
  • 4. Slide 4 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Programming for Distributed Systems communication between computer programs distributed (different processes . . . different machines) popular approaches RPC (remote procedure call) RMI (OOP-ish RPC) Messaging (SOAP, MQs) ...
  • 5. Slide 5 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Representational State Transfer (REST) architectural style for distributed hypermedia systems
  • 6. Slide 6 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 The Idea behind REST WWW REST
  • 7. Slide 6 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 The Idea behind REST WWW distributed hypermedia system works on “Internet scale” loose coupling human users REST
  • 8. Slide 6 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 The Idea behind REST WWW REST architectural style distributed systems embracing the ideas behind the web non-human users (applications)
  • 9. Slide 6 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 The Idea behind REST WWW REST Please note: We’ll only focus on applying the REST architectural style on HTTP during this talk.
  • 10. Slide 7 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 The Main Principles of REST client-server architecture statelessness uniform interface cacheability layered system
  • 11. Slide 8 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Client-Server Architecture Request Response
  • 12. Slide 9 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Statelessness server manages resource states client manages session states »[...]each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server.« Source: Roy T. Fielding — Architectural Styles and the Design of Network-based Software Architectures
  • 13. Slide 10 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Statelessness — Examples http://google.com/search?q=uni+ulm&start=10 http://example/q?SID=61AUOh6W1TA&page=next
  • 14. Slide 10 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Statelessness — Examples http://google.com/search?q=uni+ulm&start=10 search query for “uni ulm” second result page http://example/q?SID=61AUOh6W1TA&page=next
  • 15. Slide 10 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Statelessness — Examples http://google.com/search?q=uni+ulm&start=10 search query for “uni ulm” second result page http://example/q?SID=61AUOh6W1TA&page=next server maintains sessions for each search process SID contains session variable server must check state of session (i.e. search term) apply new action (i.e. next page)
  • 16. Slide 10 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Statelessness — Examples http://google.com/search?q=uni+ulm&start=10 search query for “uni ulm” second result page × http://example/q?SID=61AUOh6W1TA&page=next server maintains sessions for each search process SID contains session variable server must check state of session (i.e. search term) apply new action (i.e. next page)
  • 17. Slide 11 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Uniform Interface set of distinct methods generic operations methods of interface ∼ verbs cf. component interface design pattern
  • 18. Slide 12 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 HTTP Methods safe idempotent cachable1 HEAD GET PUT DELETE POST 1 possible
  • 19. Slide 13 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CRUD Verbs for Resources C create PUT create resource; client knows URI a-priori POST create resource; server chooses URI of new resource R read GET retrieve resource U update PUT change resource D delete DELETE remove resource
  • 20. Slide 14 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Constraints due to the Uniform Interface identification of resources manipulation of resources through representations self-descriptive messages hypermedia as the engine of application state
  • 21. Slide 15 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Identification of Resources “nouns” of the application fine-grained entities addressable through URIs Examples http://portal/user/4711 http://shop/customer/23/order/8 http://blog/post/the-post-title/comments http://search/query?term=foo
  • 22. Slide 16 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Manipulation of Resources through Representations GET /resource/4711 200 OK PUT /resource/4711 200 OK
  • 23. Slide 17 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Self-descriptive Messages messages contain representations of resources descriptitve data available in HTTP headers also useful for intermediate proxies
  • 24. Slide 18 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Self-descriptive Messages (2) popular representations for RESTful applications XML JSON HTML representations can be negotiated HTTP Request Headers: Accept, Accept-Language, Accept-Encoding HTTP Response Headers: Content-Type, Content-Language, Content-Encoding HTTP Responses: 300 Multiple Choices, 406 Not Acceptable
  • 25. Slide 19 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Hypermedia as the Engine of Application State Linking resources /users {"users" : [ GET /users { "id": 23, "link" : "/user/23" }, 200 OK { "id": 42, "link" : "/user/42" } ]} /user/23 {"user" : { GET /user/23 "id" : 23, "name" : "foobar", "details" { ... 200 OK } }}
  • 26. Slide 20 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Hypermedia as the Engine of Application State (2) Creating resources through factory resources POST /users HTTP/1.1 Host: foo.x ... Content-Type: application/json POST /users {"user" : { "name" : "qwerty", "details" { ... } 201 Created }} HTTP/1.1 201 Created Location: http://foo.x/user/12 ...
  • 27. Slide 21 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 REST Triangle Nouns URIs http://host/user/4711 Verbs HTTP Methods GET, PUT,… Representations Content-Types XML, JSON, HTML,…
  • 28. Use CaseRESTful API
  • 29. Slide 23 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 REST: Further Readings Dissertation of Roy Thomas Fielding (Original source) http://www.ics.uci.edu/~fielding/pubs/ dissertation/top.htm (Chapter 5) Books Richardson, Leonard; Ruby, Sam: RESTful Web Services (O’Reilly) Stefan Tilkov: REST und HTTP (dpunkt Verlag) Articles http://tomayko.com/writings/rest-to-my-wife
  • 30. Part II: CouchDB
  • 31. Jacob Kaplan-Moss (Django Developer) »Django may be built for the Web, but CouchDB is built of the Web. I’ve never seen software that so completely embraces the philosophies behind HTTP.«
  • 32. NoSQL
  • 33. NoSQLNot Only SQL
  • 34. Slide 27 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 SQL relational algebra database schemes powerful (ad-hoc) queries transactional behaviour blocking consistency ACID A atomicity C consistency I isolation D durability
  • 35. Slide 28 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 SQL. . . but Think of large data sets (i.e. Facebook profiles) many concurrent reads/writes (i.e. Tweets) oops RDBMS are really hard to scale reads are hard writes are even harder
  • 36. Slide 29 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 NoSQL dedicated database architecture special purposes: scalability, read/write performance, . . . BASE BA basically available S soft state E eventually consistent
  • 37. Slide 30 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 NoSQL. . . but weak(er) consistency models generally less features querying no SQL (sic) ad-hoc queries difficult or even not possible i.e. MapReduce instead
  • 38. Slide 31 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CAP Theorem Availability Consistency Partition Tolerance
  • 39. Slide 31 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CAP Theorem (pick two) Relational Database Management Systems Availability Consistency Partition Tolerance Eventual Consistency
  • 40. Slide 32 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 NoSQL Databases Document Stores Wide Column Stores Graph Databases Key-Value Stores
  • 41. Slide 32 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 NoSQL Databases Document Stores “documents” ∼ structured, but schemaless data sets Examples: CouchDB, MongoDB Wide Column Stores Graph Databases Key-Value Stores
  • 42. Slide 32 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 NoSQL Databases Document Stores Wide Column Stores sparse tables / column-oriented instead of row-oriented Examples: Cassandra, HBase Graph Databases Key-Value Stores
  • 43. Slide 32 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 NoSQL Databases Document Stores Wide Column Stores Graph Databases data structured as graphs Examples: neo4j, FlockDB Key-Value Stores
  • 44. Slide 32 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 NoSQL Databases Document Stores Wide Column Stores Graph Databases Key-Value Stores cf. HashTable / HashMap Examples: Redis, Amazon Dynamo, Voldemort
  • 45. Slide 33 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB NoSQL database document store distributed architecture easy replication
  • 46. Slide 34 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB (2) written in Erlang documents stored as JSON RESTful HTTP API MapReduce functions (JavaScript) for views
  • 47. Slide 35 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 JSON JavaScript Object Notation leightweight data-interchange format types string, number, boolean, null structures array, object
  • 48. Slide 36 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 JSON — Example 1 { 2 "boolean" : true, 3 "array" : ["foo","bar"], 4 "object" : { 5 "key" : "value", 6 "num" : 123 7 } 8 }
  • 49. Slide 37 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Documents JSON two required fields _id _rev (versioning/concurrency control) Example: 1 { 2 "_id": "58fb1df368cd2f9fef8e387508000f6d", 3 "_rev": "1-ddc8d18e4d30f529608ec65d7e7879f2", 4 "name": "cauliflower soup", 5 "type": "soup", 6 "labels": [ 7 "organic", 8 "veggie" 9 ] 10 }
  • 50. Slide 38 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 RESTful API: Create a Database benjamin@cronos:~$ curl -i -X PUT http://localhost:5984/mensaplan HTTP/1.1 201 Created Server: CouchDB/1.1.0a7446e91-git (Erlang OTP/R13B) Location: http://localhost:5984/mensaplan Date: Thu, 27 Jan 2011 12:55:29 GMT Content-Type: application/json;charset=utf-8 Content-Length: 12 Cache-Control: must-revalidate {"ok":true}
  • 51. Slide 39 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 RESTful API: Create a Database (2) Let’s try again. . . benjamin@cronos:~$ curl -i -X PUT http://localhost:5984/mensaplan HTTP/1.1 412 Precondition Failed Server: CouchDB/1.1.0a7446e91-git (Erlang OTP/R13B) Date: Thu, 27 Jan 2011 12:57:30 GMT Content-Type: application/json;charset=utf-8 Content-Length: 95 Cache-Control: must-revalidate {"error":"file_exists","reason":"The database could not be created, the file already exists."}
  • 52. Slide 40 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 RESTful API: Delete a Database benjamin@cronos:~$ curl -i -X DELETE http://localhost:5984/mensaplan HTTP/1.1 200 OK Server: CouchDB/1.1.0a7446e91-git (Erlang OTP/R13B) Date: Thu, 27 Jan 2011 13:01:39 GMT Content-Type: application/json;charset=utf-8 Content-Length: 12 Cache-Control: must-revalidate {"ok":true}
  • 53. Slide 41 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 RESTful API: Create a Document benjamin@cronos:~$ curl -i -X POST -H "Content-Type: application/json" -d ’{"name":" goulash","type":"main","labels":["pork"]}’ http://localhost:5984/mensaplan HTTP/1.1 201 Created Server: CouchDB/1.1.0a7446e91-git (Erlang OTP/R13B) Location: http://localhost:5984/mensaplan/ad8592f32ccd34f0588b86f5a9000fd3 Date: Thu, 27 Jan 2011 13:04:09 GMT Content-Type: application/json;charset=utf-8 Content-Length: 95 Cache-Control: must-revalidate {"ok":true,"id":"ad8592f32ccd34f0588b86f5a9000fd3","rev":"1-5 bb3c72e38c6c7aaa7a2d4fd578478e7"}
  • 54. Slide 42 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 RESTful API: Get a Document benjamin@cronos:~$ curl -i -X GET http://localhost:5984/mensaplan/ ad8592f32ccd34f0588b86f5a9000fd3 HTTP/1.1 200 OK Server: CouchDB/1.1.0a7446e91-git (Erlang OTP/R13B) Etag: "1-5bb3c72e38c6c7aaa7a2d4fd578478e7" Date: Thu, 27 Jan 2011 13:07:27 GMT Content-Type: application/json;charset=utf-8 Content-Length: 136 Cache-Control: must-revalidate {"_id":"ad8592f32ccd34f0588b86f5a9000fd3","_rev":"1-5bb3c72e38c6c7aaa7a2d4fd578478e7" ,"name":"goulash","type":"main","labels":["pork"]}
  • 55. Slide 43 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 RESTful API: Update a Document benjamin@cronos:~$ curl -i -X PUT -H "Content-Type: application/json" -d ’{"name":" goulash","type":"main","labels":["pork","organic"]}’ http://localhost:5984/ mensaplan/ad8592f32ccd34f0588b86f5a9000fd3 HTTP/1.1 409 Conflict Server: CouchDB/1.1.0a7446e91-git (Erlang OTP/R13B) Date: Thu, 27 Jan 2011 13:08:53 GMT Content-Type: application/json;charset=utf-8 Content-Length: 58 Cache-Control: must-revalidate {"error":"conflict","reason":"Document update conflict."}
  • 56. Slide 44 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 RESTful API: Update a Document (doing it right) benjamin@cronos:~$ curl -i -X PUT -H "Content-Type: application/json" -d ’{"name":" goulash","type":"main","labels":["pork","organic"]}’ http://localhost:5984/ mensaplan/ad8592f32ccd34f0588b86f5a9000fd3 -H ’If-Match: "1-5 bb3c72e38c6c7aaa7a2d4fd578478e7"’ HTTP/1.1 201 Created Server: CouchDB/1.1.0a7446e91-git (Erlang OTP/R13B) Location: http://localhost:5984/mensaplan/ad8592f32ccd34f0588b86f5a9000fd3 Etag: "2-8ebf81b724635a1b625cc1a66e0e5263" Date: Thu, 27 Jan 2011 13:10:41 GMT Content-Type: application/json;charset=utf-8 Content-Length: 95 Cache-Control: must-revalidate {"ok":true,"id":"ad8592f32ccd34f0588b86f5a9000fd3","rev":"2-8 ebf81b724635a1b625cc1a66e0e5263"}
  • 57. MapReduce?
  • 58. http://www.flickr.com/photos/bdesham/2432400623
  • 59. Slide 47 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 MapReduce
  • 60. Slide 47 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 MapReduce map
  • 61. Slide 47 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 MapReduce 2x 3x 1x 1x map 3x 2x 2x
  • 62. Slide 47 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 MapReduce 2x 3x 1x 1x map reduce 3x 2x 2x
  • 63. Slide 47 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 MapReduce 2x 3x 1x 1x 2x map reduce 6x 3x 3x 3x 2x 2x
  • 64. Source: http://browsertoolkit.com/fault-tolerance.png
  • 65. Slide 49 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB Views with MapReduce views ∼ B+ trees incremental tuples of <key, value> items sorted by key complex keys possible (JSON)
  • 66. Slide 50 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 View Example: List organic food only map 1 function(doc){ 2 if(doc.labels){ 3 for(var idx in doc.labels){ 4 if(doc.labels[idx] === "organic"){ 5 emit(doc._id, doc.name); 6 } 7 } 8 } 9 }
  • 67. Slide 51 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Querying the View benjamin@cronos:~$ curl -i http://localhost:5984/mensaplan/_design/couchapp/_view/ organic HTTP/1.1 200 OK Transfer-Encoding: chunked Server: CouchDB/1.1.0a7446e91-git (Erlang OTP/R13B) Etag: "7GW4ZJ7D8F2T2OCFL7VJO5AO6" Date: Thu, 27 Jan 2011 14:26:35 GMT Content-Type: text/plain;charset=utf-8 Cache-Control: must-revalidate {"total_rows":2,"offset":0,"rows":[ {"id":"58fb1df368cd2f9fef8e387508000f6d","key":"58fb1df368cd2f9fef8e387508000f6d"," value":"cauliflower soup"}, {"id":"58fb1df368cd2f9fef8e387508001149","key":"58fb1df368cd2f9fef8e387508001149"," value":"spaghetti napoli"} ]}
  • 68. Slide 52 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 View Example: Count dishes in database map 1 function(doc){ 2 if(doc.type){ 3 emit(doc.type, 1); 4 } 5 } reduce 1 function (key, values, rereduce) { 2 return sum(values); 3 }
  • 69. Slide 53 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Querying the View (without reduce) benjamin@cronos:~$ curl -i http://localhost:5984/mensaplan/_design/couchapp/_view/ dishes?reduce=false HTTP/1.1 200 OK Transfer-Encoding: chunked Server: CouchDB/1.1.0a7446e91-git (Erlang OTP/R13B) Etag: "B3JLG6SIRJKRHCRNIQSEAH6GL" Date: Thu, 27 Jan 2011 14:15:25 GMT Content-Type: text/plain;charset=utf-8 Cache-Control: must-revalidate {"total_rows":3,"offset":0,"rows":[ {"id":"58fb1df368cd2f9fef8e387508001149","key":"main","value":1}, {"id":"58fb1df368cd2f9fef8e3875080012d4","key":"main","value":1}, {"id":"58fb1df368cd2f9fef8e387508000f6d","key":"soup","value":1} ]}
  • 70. Slide 54 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Querying the View benjamin@cronos:~$ curl -i http://localhost:5984/mensaplan/_design/couchapp/_view/ dishes HTTP/1.1 200 OK Transfer-Encoding: chunked Server: CouchDB/1.1.0a7446e91-git (Erlang OTP/R13B) Etag: "B3JLG6SIRJKRHCRNIQSEAH6GL" Date: Thu, 27 Jan 2011 14:16:16 GMT Content-Type: text/plain;charset=utf-8 Cache-Control: must-revalidate {"rows":[ {"key":null,"value":3} ]}
  • 71. Slide 55 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Querying the View: Grouping benjamin@cronos:~$ curl -i http://localhost:5984/mensaplan/_design/couchapp/_view/ dishes?group=true HTTP/1.1 200 OK Transfer-Encoding: chunked Server: CouchDB/1.1.0a7446e91-git (Erlang OTP/R13B) Etag: "B3JLG6SIRJKRHCRNIQSEAH6GL" Date: Thu, 27 Jan 2011 14:17:41 GMT Content-Type: text/plain;charset=utf-8 Cache-Control: must-revalidate {"rows":[ {"key":"main","value":2}, {"key":"soup","value":1} ]}
  • 72. Slide 56 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Replication unidirectional or bidirectional snapshotted or continuous Watch out! conflicts possible conflict resolution necessary Multiversion Concurrency Control
  • 73. Slide 57 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Replication — Example: Bidirectional
  • 74. Slide 58 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Replication — Example: Master Slave Writes Reads
  • 75. Slide 59 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Replication — Example: Peer-to-Peer
  • 76. Slide 60 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Web Interface: Futon
  • 77. Slide 61 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Other CouchDB Features _show _list _changes validate_doc_update
  • 78. Slide 61 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Other CouchDB Features _show regular documents are JSON objects _show functions render other formats i.e. HTML page _list _changes validate_doc_update
  • 79. Slide 61 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Other CouchDB Features _show _list regular view results are encoded in JSON _list functions convert results into custom formats i.e. RSS feed _changes validate_doc_update
  • 80. Slide 61 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Other CouchDB Features _show _list _changes change notification fires on new document, updates, etc. HTTP (long) polling, continuous validate_doc_update
  • 81. Slide 61 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Other CouchDB Features _show _list _changes validate_doc_update validation routine checks if document change is valid
  • 82. Slide 62 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Some Interesting CouchDB Projects CouchApp CouchDB Lounge / BigCouch GeoCouch CouchDB-Lucene
  • 83. Slide 62 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Some Interesting CouchDB Projects CouchApp standalone web applications with CouchDB CouchDB serves client-side HTML + JavaScript CouchDB Lounge / BigCouch GeoCouch CouchDB-Lucene
  • 84. Slide 62 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Some Interesting CouchDB Projects CouchApp CouchDB Lounge / BigCouch clustering extensions proxy-based partitioning/clustering GeoCouch CouchDB-Lucene
  • 85. Slide 62 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Some Interesting CouchDB Projects CouchApp CouchDB Lounge / BigCouch GeoCouch spatial indexes for CouchDB efficient geo-spatial queries CouchDB-Lucene
  • 86. Slide 62 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Some Interesting CouchDB Projects CouchApp CouchDB Lounge / BigCouch GeoCouch CouchDB-Lucene full text search for CouchDB separate index based on Lucene (Java)
  • 87. Live DemoCouchDB & Futon
  • 88. Slide 64 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB: Further Readings Books J. Chris Anderson; Jan Lehnardt; Noah Slater — CouchDB: The Definitive Guide (O’Reilly) Open Source Book: http://guide.couchdb.org/index.html Stefan Edlich, Achim Friedland, Jens Hampe, Benjamin Brauer — NoSQL (HANSER Verlag) Websites http://nosqltapes.com http://www.couchone.com/get
  • 89. Slide 65 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Discussion Thanks for your attention. Any questions?
  • 90. Slide 66 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 License Slides incorporate contents form. . . picol.org flickr.com/photos/daveaustria flickr.com/photos/bdesham github.com/oreilly/couchdb-guide
  • 91. Backup Slides
  • 92. Slide 68 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Distributed Systems – Motivation single computer limited resources limited computing power limited storage single point of failure
  • 93. Slide 69 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Distributed Systems – Motivation many computers more resources more computing power more storage non-functional benefits (i.e. fault-tolerance)
  • 94. Slide 69 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Distributed Systems – Motivation many computers more resources more computing power more storage non-functional benefits (i.e. fault-tolerance) but also more complex systems more sources of trouble
  • 95. Slide 70 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Distributed Systems – Different Approaches environments distributed operating systems middleware systems standalone applications ... interaction models shared memory request/reply message-based ...
  • 96. Slide 71 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Distributed Systems – Some Requirements identifiers for resources (what?) location/naming services (where?) communication services/protocols (how?) software support (how to use?)
  • 97. Slide 72 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 Historical Approach: RPC Remote Procedure Calls add(1,2); add(1,2) A B 1+2=3 return 3 Examples: Sun RPC (NFS)
  • 98. Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB: MVCC / Conflicts Source: CouchDB — The Definitive Guide
  • 99. Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB: MVCC / Conflicts Source: CouchDB — The Definitive Guide
  • 100. Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB: MVCC / Conflicts Source: CouchDB — The Definitive Guide
  • 101. Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB: MVCC / Conflicts Source: CouchDB — The Definitive Guide
  • 102. Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB: MVCC / Conflicts Source: CouchDB — The Definitive Guide
  • 103. Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB: MVCC / Conflicts Source: CouchDB — The Definitive Guide
  • 104. Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB: MVCC / Conflicts Source: CouchDB — The Definitive Guide
  • 105. Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB: MVCC / Conflicts Source: CouchDB — The Definitive Guide
  • 106. Slide 74 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011 CouchDB: Append-only B+ Tree Source: CouchDB — The Definitive Guide