Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

and Erlang

litaocheng@gmail.com
2009.8.29

Apache CouchDB has started.


Time to relax.

About This Talk


CouchDB
CouchDB
CouchDB Internal
Erlang

What's CouchDB
Damien Katz<http://damienkatz.net/>
Worked on Lotus Notes & MySQL
2005: C++, XML, on Windows
2006Erlang, JSON, POSIX
0.7.0 Erlang
Apache
0.9.1

CouchDB Next Release(0.10)


cookie OAuth
Windows

HTTPRFC 2616

Native Erlang View Server)


Filter API
Update API

Why CouchDB?
Document DBJSON
Schema-Free
HTTP RESTful Web
CouchDB Replicationoffline
ACID Storage Engine
MVCC
Views With MapReduce
Single Storage File,
Fault Tolerant

CouchDB
Standalone ():
MVCC()
Append
ACID
Distributed ()
CouchDB Document Partition
ReplicationAvailabity Scalability
Eventual Consistency by using Incremental
Replication

CouchDB

CouchDB
API
JSON
Document
View
ACID
MVCC

CouchDB API
HTTP

CouchDB RUD

GET

read

PUT

create or update

DELETE

delete

POST

bulk operation
)

HTTPCouchDB API

JSON Documents
{
_id
_rev
title
author
tags
post_date
content

:
:
:
:
:
:
:

some uuid,
mvcc key,
a blog post,
foo,
[life, happy],
2008-08-30 15:30:26,
this is an blog....

}
DocumentJsonDocuments
RDBM
Schema-Free,,JS

Document and couch file

DB File
All Documents is self Contained

RDBM

Schema Alter, Data migrating, Scalicability ....


We Need NOSQL?

View

view index
BTreekeykey-range
DB(*.couch)view
map, reduceDBview
javascript view server
view server( java?
c/c++)

View
javascript)
storage(.couch)
:
view
design documents view
view indexview(BTree)
view
POST DATAview
Querying Options - startkey, endkye, limit ...

View example(js)
map fun:
function(doc) {
emit(doc.post_date, doc.title);
}
result(BTree, sorted):
|
key
|
value
|
-----------------------------------------| "2008-08-30 15:30:06" | "a blog post" |
| "2008-08-31 20:31:24", | "second post" |
| "2008-09-01 10:10:21", | "third post" |
blog post

ACID
Storage (double header)
Appendoverwirte,commit log
crash-only
MVCC, read),write
2BTreedocidseqidkey
:
1. storage
2. header(4K)

consistency

Locking
vs
Multi Version Concurrency Control

Attachment
Inline Attachments
document
base64
Standalone Attachments
textdocument
storage
Create HTTP PUT
Change HTTP PUTrev
Delete - HTTP DELETE rev

CouchDB Internal

CouchDB Internal - Storage


.couchHeaderBody
magic code:$g, $m, $k, 0
2048 2header

headerroot
BTree
kv nodekp node

rootappendcouch

CouchDB Internal - compaction


Append
couchcompaction
dbname.compactdb
dbcompact
CouchDB

compaction

CouchDB Internal - Replication


document and design can replicate
incremental replication
replication

seq num
continues replaction "_changes" API

CouchDB Internal - View


Default View Language : Javascript
Js engine : Mozila SpiderMonkey
couchjs /server/main.js view server
dbcouch_view_updaterview
view view index

Erlang
Ericsson,
(FP)
(OC),

SMP
OTP
, , 20
, ,
Open Source,

Erlang

GC

OTPcallback

bytecode),

grep
...

Erlang""
FPOO
Single Assign
Record
stringlistbinary
...


Erlang.


blog:
http://mryufeng.javaeye.com
http://www.joeandmotorboat.com/
http://damienkatz.net/
http://jchrisa.net/
http://jan.prima.de/plok/
http://johnpwood.net/
http://userprimary.net/user/
website:
http://www.erlang.org
http://www.erlang-china.org
http://erlang-factory.com/
http://planet.couchdb.org/
http://wiki.apache.org/couchdb/

Books

http://books.couchdb.org/relax/

CouchDB & Erlang

Relax!
Thanks everyone!

You might also like