introduction to rest & couchdb
DESCRIPTION
A presentation introducing REST and CouchDB given at the "Web Enigineering" course at Ulm University, 2011/01/28.TRANSCRIPT
Introduction toREST & CouchDB
Benjamin Erb | 28.01.2011 | Universität Ulm Web Engineering WS10/11
Slide 2 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Introduction
I Benjamin ErbI http://twitter.com/b_erb
I http://github.com/berb
I http://www.benjamin-erb.de
I student of computer sciene & media informaticsI Ulm University, Germany
Part I: REST
Slide 4 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Programming for Distributed Systems
I communication between computer programsI distributed (different processes . . . different machines)I popular approaches
I RPC (remote procedure call)I RMI (OOP-ish RPC)I Messaging (SOAP, MQs)I . . .
Slide 5 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Representational State Transfer (REST)
architectural style for distributed hypermediasystems
Slide 6 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
The Idea behind REST
WWW
REST
Slide 6 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
The Idea behind REST
WWW
I distributed hypermedia systemI works on “Internet scale”I loose couplingI human users
REST
Slide 6 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
The Idea behind REST
WWW
REST
I architectural styleI distributed systemsI embracing the ideas behind the webI non-human users (applications)
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 architecturalstyle on HTTP during this talk.
Slide 7 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
The Main Principles of REST
I client-server architectureI statelessnessI uniform interfaceI cacheabilityI layered system
Slide 8 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Client-Server Architecture
Request
Response
Slide 9 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Statelessness
I server manages resource statesI 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
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
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
I search query for “uni ulm”I second result page
http://example/q?SID=61AUOh6W1TA&page=next
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
I search query for “uni ulm”I second result page
http://example/q?SID=61AUOh6W1TA&page=next
I server maintains sessions for each search processI SID contains session variableI server must check state of session (i.e. search term)I apply new action (i.e. next page)
Slide 10 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Statelessness — Examples
X http://google.com/search?q=uni+ulm&start=10
I search query for “uni ulm”I second result page
× http://example/q?SID=61AUOh6W1TA&page=next
I server maintains sessions for each search processI SID contains session variableI server must check state of session (i.e. search term)I apply new action (i.e. next page)
Slide 11 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Uniform Interface
I set of distinct methodsI generic operationsI methods of interface ∼ verbsI cf. component interface design pattern
Slide 12 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
HTTP Methods
safe idempotent cachable1
HEAD X X XGET X X XPUT X
DELETE XPOST
1possible
Slide 13 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CRUD Verbs for ResourcesC createPUT create resource; client knows URI a-priori
POST create resource; server chooses URI of new resourceR readGET retrieve resource
U updatePUT change resource
D deleteDELETE remove resource
Slide 14 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Constraints due to the Uniform Interface
I identification of resourcesI manipulation of resources through representationsI self-descriptive messagesI hypermedia as the engine of application state
Slide 15 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Identification of Resources
I “nouns” of the applicationI fine-grained entitiesI addressable through URIs
ExamplesI http://portal/user/4711
I http://shop/customer/23/order/8
I http://blog/post/the-post-title/comments
I http://search/query?term=foo
Slide 16 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Manipulation of Resources through Representations
GET /resource/4711
PUT /resource/4711
200 OK
200 OK
Slide 17 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Self-descriptive Messages
I messages contain representations of resourcesI descriptitve data available in HTTP headersI also useful for intermediate proxies
Slide 18 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Self-descriptive Messages (2)I popular representations for RESTful applications
I XMLI JSONI HTML
I representations can be negotiatedI HTTP Request Headers: Accept, Accept-Language,Accept-Encoding
I HTTP Response Headers: Content-Type,Content-Language, Content-Encoding
I HTTP Responses: 300 Multiple Choices, 406 NotAcceptable
Slide 19 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Hypermedia as the Engine of Application State
Linking resources
GET /users
GET /user/23
200 OK
200 OK
/users{"users" : [ { "id": 23, "link" : "/user/23" }, { "id": 42, "link" : "/user/42" }]}
/user/23{"user" : { "id" : 23, "name" : "foobar", "details" { ... }}}
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
201 Created
POST /users HTTP/1.1Host: foo.x...Content-Type: application/json
{"user" : { "name" : "qwerty", "details" { ... }}}
HTTP/1.1 201 CreatedLocation: http://foo.x/user/12...
Slide 21 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
REST Triangle
NounsURIshttp://host/user/4711
RepresentationsContent-TypesXML, JSON, HTML,…
VerbsHTTP MethodsGET, PUT,…
Use Case
RESTful API
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)I http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm (Chapter 5)
BooksI Richardson, Leonard; Ruby, Sam: RESTful Web Services
(O’Reilly)I Stefan Tilkov: REST und HTTP (dpunkt Verlag)
ArticlesI http://tomayko.com/writings/rest-to-my-wife
Part II: CouchDB
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.«
NoSQL
NoSQLNot Only SQL
Slide 27 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
SQL
I relational algebraI database schemesI powerful (ad-hoc) queriesI transactional behaviourI blocking consistencyI ACID
A atomicityC consistencyI isolation
D durability
Slide 28 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
SQL. . . but
Think ofI large data sets (i.e. Facebook profiles)I many concurrent reads/writes (i.e. Tweets)
oopsI RDBMS are really hard to scale
I reads are hardI writes are even harder
Slide 29 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
NoSQL
I dedicated database architectureI special purposes: scalability, read/write performance, . . .I BASE
BA basically availableS soft stateE eventually consistent
Slide 30 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
NoSQL. . . but
I weak(er) consistency modelsI generally less featuresI querying
I no SQL (sic)I ad-hoc queries difficult or even not possibleI i.e. MapReduce instead
Slide 31 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CAP Theorem
Consistency
Availability
Partition Tolerance
Slide 31 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CAP Theorem (pick two)
Consistency
Availability
Partition Tolerance Eventual
Consistency
Relational Database Management Systems
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
Slide 32 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
NoSQL Databases
Document Stores
I “documents” ∼ structured, but schemaless data setsI Examples: CouchDB, MongoDB
Wide Column Stores
Graph Databases
Key-Value Stores
Slide 32 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
NoSQL Databases
Document Stores
Wide Column Stores
I sparse tables / column-oriented instead of row-orientedI Examples: Cassandra, HBase
Graph Databases
Key-Value Stores
Slide 32 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
NoSQL Databases
Document Stores
Wide Column Stores
Graph Databases
I data structured as graphsI Examples: neo4j, FlockDB
Key-Value Stores
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
I cf. HashTable / HashMapI Examples: Redis, Amazon Dynamo, Voldemort
Slide 33 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CouchDB
I NoSQL databaseI document storeI distributed architectureI easy replication
Slide 34 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CouchDB (2)
I written in ErlangI documents stored as JSONI RESTful HTTP APII MapReduce functions (JavaScript) for views
Slide 35 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
JSON
I JavaScript Object NotationI leightweight data-interchange formatI types
I string, number, boolean, nullI structures
I array, object
Slide 36 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
JSON — Example1 {2 "boolean" : true,3 "array" : ["foo","bar"],4 "object" : {5 "key" : "value",6 "num" : 1237 }8 }
Slide 37 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Documents
I JSONI two required fields
I _idI _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 }
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}
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."}
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}
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"}
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"]}
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."}
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"}
MapReduce?
http://www.flickr.com/photos/bdesham/2432400623
Slide 47 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
MapReduce
Slide 47 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
MapReduce
map
Slide 47 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
MapReduce
2x
3x
1x
1x
3x
2x
2x
map
Slide 47 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
MapReduce
2x
3x
1x
1x
3x
2x
2x
map reduce
Slide 47 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
MapReduce
2x
3x
1x
1x
3x
2x
2x
2x
6x
3x
3x
map reduce
Source: http://browsertoolkit.com/fault-tolerance.png
Slide 49 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CouchDB Views with MapReduce
I views ∼ B+ treesI incrementalI tuples of <key, value>I items sorted by keyI complex keys possible (JSON)
Slide 50 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
View Example: List organic food only
map1 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 }
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"}
]}
Slide 52 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
View Example: Count dishes in database
map1 function(doc){2 if(doc.type){3 emit(doc.type, 1);4 }5 }
reduce1 function (key, values, rereduce) {2 return sum(values);3 }
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}
]}
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}
]}
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}
]}
Slide 56 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Replication
I unidirectional or bidirectionalI snapshotted or continuous
Watch out!I conflicts possibleI conflict resolution necessaryI Multiversion Concurrency Control
Slide 57 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Replication — Example: Bidirectional
Slide 58 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Replication — Example: Master Slave
Writes Reads
Slide 59 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Replication — Example: Peer-to-Peer
Slide 60 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Web Interface: Futon
Slide 61 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Other CouchDB Features
_show
_list
_changes
validate_doc_update
Slide 61 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Other CouchDB Features
_show
I regular documents are JSON objectsI _show functions render other formatsI i.e. HTML page
_list
_changes
validate_doc_update
Slide 61 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Other CouchDB Features
_show
_list
I regular view results are encoded in JSONI _list functions convert results into custom formatsI i.e. RSS feed
_changes
validate_doc_update
Slide 61 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Other CouchDB Features
_show
_list
_changes
I change notificationI fires on new document, updates, etc.I HTTP (long) polling, continuous
validate_doc_update
Slide 61 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Other CouchDB Features
_show
_list
_changes
validate_doc_update
I validation routineI checks if document change is valid
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
Slide 62 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Some Interesting CouchDB Projects
CouchApp
I standalone web applications with CouchDBI CouchDB serves client-side HTML + JavaScript
CouchDB Lounge / BigCouch
GeoCouch
CouchDB-Lucene
Slide 62 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Some Interesting CouchDB Projects
CouchApp
CouchDB Lounge / BigCouch
I clustering extensionsI proxy-based partitioning/clustering
GeoCouch
CouchDB-Lucene
Slide 62 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Some Interesting CouchDB Projects
CouchApp
CouchDB Lounge / BigCouch
GeoCouch
I spatial indexes for CouchDBI efficient geo-spatial queries
CouchDB-Lucene
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
I full text search for CouchDBI separate index based on Lucene (Java)
Live Demo
CouchDB & Futon
Slide 64 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CouchDB: Further Readings
BooksI J. Chris Anderson; Jan Lehnardt; Noah Slater — CouchDB:
The Definitive Guide (O’Reilly)I Open Source Book:http://guide.couchdb.org/index.html
I Stefan Edlich, Achim Friedland, Jens Hampe, BenjaminBrauer — NoSQL (HANSER Verlag)
WebsitesI http://nosqltapes.comI http://www.couchone.com/get
Slide 65 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Discussion
Thanks for your attention.
Any questions?
Slide 66 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
License
Slides incorporate contents form. . .I picol.orgI flickr.com/photos/daveaustriaI flickr.com/photos/bdeshamI github.com/oreilly/couchdb-guide
Backup Slides
Slide 68 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Distributed Systems – Motivation
single computerI limited resourcesI limited computing powerI limited storageI single point of failure
Slide 69 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Distributed Systems – Motivation
many computersI more resourcesI more computing powerI more storageI non-functional benefits (i.e. fault-tolerance)
Slide 69 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Distributed Systems – Motivation
many computersI more resourcesI more computing powerI more storageI non-functional benefits (i.e. fault-tolerance)
but alsoI more complex systemsI more sources of trouble
Slide 70 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Distributed Systems – Different Approaches
environmentsI distributed operating systemsI middleware systemsI standalone applicationsI . . .
interaction modelsI shared memoryI request/replyI message-basedI . . .
Slide 71 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Distributed Systems – Some Requirements
I identifiers for resources (what?)I location/naming services (where?)I communication services/protocols (how?)I software support (how to use?)
Slide 72 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
Historical Approach: RPC
Remote Procedure Calls
add(1,2)
return 3
1+2=3A B
add(1,2);
I Examples: Sun RPC (NFS)
Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CouchDB: MVCC / Conflicts
Source: CouchDB — The Definitive Guide
Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CouchDB: MVCC / Conflicts
Source: CouchDB — The Definitive Guide
Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CouchDB: MVCC / Conflicts
Source: CouchDB — The Definitive Guide
Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CouchDB: MVCC / Conflicts
Source: CouchDB — The Definitive Guide
Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CouchDB: MVCC / Conflicts
Source: CouchDB — The Definitive Guide
Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CouchDB: MVCC / Conflicts
Source: CouchDB — The Definitive Guide
Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CouchDB: MVCC / Conflicts
Source: CouchDB — The Definitive Guide
Slide 73 Introduction to REST & CouchDB | Web Engineering WS10/11 | Benjamin Erb | 28.01.2011
CouchDB: MVCC / Conflicts
Source: CouchDB — The Definitive Guide
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