introduction into couchdb / jan lehnardt

46
CouchDB

Upload: bbc-web-developers

Post on 09-Jun-2015

5.646 views

Category:

Business


1 download

DESCRIPTION

In this talk - Jan Lenhnardt introduces Apache CouchDB. CouchDB is a distributed, fault-tolerant and schema-free document-oriented database accessible via a RESTful HTTP/JSON API. Among other features, it provides robust, incremental replication with bi-directional conflict detection and resolution, and is queryable and indexable using a table-oriented view engine with JavaScript acting as the default view definition language. A video of this talk can be found at http://bbcwebdevelopers.blip.tv/ as

TRANSCRIPT

Page 1: Introduction into CouchDB / Jan Lehnardt

CouchDB

Page 2: Introduction into CouchDB / Jan Lehnardt

Who’s talking?

Jan Lehnardt, project member, web developer, curious person.

[email protected] / @janl

Page 3: Introduction into CouchDB / Jan Lehnardt

And you?

What can you expect today?

Page 4: Introduction into CouchDB / Jan Lehnardt

Built for the Future“640k processors should be enough for anybody.”

Page 5: Introduction into CouchDB / Jan Lehnardt

Single-user machinesBack then

Page 6: Introduction into CouchDB / Jan Lehnardt

Multi-user machinesNow

Page 7: Introduction into CouchDB / Jan Lehnardt

Application: ScienceBack then

Page 8: Introduction into CouchDB / Jan Lehnardt

Application: InternetToday

Page 9: Introduction into CouchDB / Jan Lehnardt

Monolithic machinesBack then

Page 10: Introduction into CouchDB / Jan Lehnardt

Lots of small serversToday

Page 11: Introduction into CouchDB / Jan Lehnardt

CPU, RAM and disks == $$$Back then

Page 12: Introduction into CouchDB / Jan Lehnardt

Components cheaperNow

Page 13: Introduction into CouchDB / Jan Lehnardt

RDBMS vsJust Storing Data

Page 14: Introduction into CouchDB / Jan Lehnardt

RDBMS vs Just Storing Data

Design schema upfront

Write or use software to translate your data into that schema

…and back1) beware of speed considerations without having an app to measure2) or use an ORM which turns out to be a pain in the back for all sorts of reasons3) Most Data is not inherently relational

Page 15: Introduction into CouchDB / Jan Lehnardt

RDBMS vs Just Storing Data

Isolated data records called Documents

No schema (!)

data records that make up the app’s data objects

Page 16: Introduction into CouchDB / Jan Lehnardt

Documents in the Real World

Page 17: Introduction into CouchDB / Jan Lehnardt

Documents in the Real World

Bills, tax forms, letters…

Same type != same structure

Can be out of date

Natural data behaviour

Actual data record, no pointer

Page 18: Introduction into CouchDB / Jan Lehnardt

CouchDB Documents

JSON Format

Similar to XML

Easy to read and write (unlike XML)

XML does too much for us

Page 19: Introduction into CouchDB / Jan Lehnardt

CouchDB Documents{ “_id”: ”BCCD12CBB”, “_rev”: ”AB764C”, “type”: ”person”, “name”: ”Darth Vader”, “age”: 63, “headware”: [“Helmet”, “Sombrero”], “dark_side”: true}

Page 20: Introduction into CouchDB / Jan Lehnardt

CouchDB Documents{ “_id”: ”BCCD12CBB”, “_rev”: ”AB764C”, “type”: ”person”, “name”: ”Darth Vader”, “age”: 63, “headware”: [“Helmet”, “Sombrero”], “dark_side”: true}

Natural type mapping between languagesRevisionsAttachments

Page 21: Introduction into CouchDB / Jan Lehnardt

CouchDB Documents{ “_id”: ”BCCD12CBB”, “_rev”: ”AB764C”, “type”: ”person”, “name”: ”Darth Vader”, “age”: 63, “headware”: [“Helmet”, “Sombrero”], “dark_side”: true}

Natural type mapping between languagesRevisionsAttachments

Page 22: Introduction into CouchDB / Jan Lehnardt

CouchDB Documents{ “_id”: ”BCCD12CBB”, “_rev”: ”AB764C”, “type”: ”person”, “name”: ”Darth Vader”, “age”: 63, “headware”: [“Helmet”, “Sombrero”], “dark_side”: true}

Natural type mapping between languagesRevisionsAttachments

Page 23: Introduction into CouchDB / Jan Lehnardt

HTTP REST API

CRUD

Page 24: Introduction into CouchDB / Jan Lehnardt

HTTP REST API

Powers the World Wide Web

Supported everywhere

Lots of tools available

Page 25: Introduction into CouchDB / Jan Lehnardt

Working With a Document – The REST API

Create: HTTP PUT /db/docid Read: HTTP GET /db/docidUpdate: HTTP POST /db/docidDelete: HTTP DELETE /db/docid

HTTP around for ages, simple, proven,scales, tools available

Page 26: Introduction into CouchDB / Jan Lehnardt

Views

Page 27: Introduction into CouchDB / Jan Lehnardt

Views

Filter, Collate, Aggregate

Powered by Map/Reduce

Design documentsfunctions get executed, you don’t do that

Page 28: Introduction into CouchDB / Jan Lehnardt

Views - Map Tags

Keys Values

family 1

friends 1

friends 1

work 1

work 1

youtube 1

… …

Page 29: Introduction into CouchDB / Jan Lehnardt

Views - Reduce Tag Count

Keys Values

family 1

friends 1

friends 1

work 1

work 1

youtube 1

… …

Keys Values

family 1

friends 2

work 2

youtube 1

… …

Page 30: Introduction into CouchDB / Jan Lehnardt

Views - Map Tags

function (doc) { for(var i in doc.tags) emit(doc.tags[i], 1);}

Page 31: Introduction into CouchDB / Jan Lehnardt

Views - Reduce Tag Count

Keys Values

family 1

friends 1

friends 1

work 1

work 1

youtube 1

… …

Keys Values

family 1

friends 2

work 2

youtube 1

… …

Page 32: Introduction into CouchDB / Jan Lehnardt

Views - Reduce Tag Count

function (Key, Values) { var sum = 0; for(var i in Values) sum += Values[i]; return sum;}

Incremental, On-demandreduce optional

Page 33: Introduction into CouchDB / Jan Lehnardt

Views

Built incrementally…

…and on demand

Reduce optional

map/reduce can be parallelised

Page 34: Introduction into CouchDB / Jan Lehnardt

Replication

Page 35: Introduction into CouchDB / Jan Lehnardt

Replication

Take your data with you

CouchDB makes it easy to synchronise machines

rsync-likeLarge spectrum of architectures: - P2P, Failover, Load Balancing, BackupConflicts: auto-detect & resolve, data consistency

Page 36: Introduction into CouchDB / Jan Lehnardt

Built for the Future

Written in Erlang - a telco-grade concurrent platform

Non-locking MVCC and ACID compliant data store

Erlang Processes + messagingEricsson AXD 301 - nine nines - 1/30th second per yearCrash resistant

Page 37: Introduction into CouchDB / Jan Lehnardt

Number Bragging

Silly read-only benchmark with memory saturation

2,500 req/s sustained on a 2Ghz dual core Athlon

Page 38: Introduction into CouchDB / Jan Lehnardt

Number Bragging

Silly read-only benchmark with memory saturation

2,500 req/s sustained on a 2Ghz dual core Athlon

Using 9.8 MB RAM

Page 39: Introduction into CouchDB / Jan Lehnardt

A Little History

Damien Katz self funded fulltime development for 2 years

Now backed by IBM

Page 40: Introduction into CouchDB / Jan Lehnardt
Page 41: Introduction into CouchDB / Jan Lehnardt

A Little History

Accepted to the Apache Software Foundation

Open Source License

Page 42: Introduction into CouchDB / Jan Lehnardt
Page 43: Introduction into CouchDB / Jan Lehnardt

Resources

http://couchdb.org/

http://couchdbwiki.com/

http://damienkatz.net/

http://jan.prima.de/

http://blog.racklabs.com/?p=74

not covered everything,other talks + tutorialshow to join

Page 44: Introduction into CouchDB / Jan Lehnardt

Hired me, thanks!$$$£££/€€€.

Page 45: Introduction into CouchDB / Jan Lehnardt

Thank YouReally, thanks.

Page 46: Introduction into CouchDB / Jan Lehnardt

Got it?Questions