36
GETTING COMFORTABLE WITH Patrick Heneise, @PatrickHeneise

Couchbase presentation - by Patrick Heneise

  • Upload
    itnig

  • View
    583

  • Download
    1

Embed Size (px)

DESCRIPTION

In the Friday training I am going to introduce CouchBase Server, a NoSQL (Not only SQL, document oriented) database and outline differences to Apache CouchDB. We're going through a quick setup of the CouchBase Server and the basics of CouchDB document design. I will show some real world examples, followed by a discussion. Who is Patrick Heneise? Patrick is the Founder & CEO of desentia. He achieved a MSc in Media Technology and BSc in Computer Science in Media. Ever since he has improved social interaction and media with creative and professional technology solutions. He started his first business in 2006 during his studies in the fields of eLearning and web technologies and worked for various companies and universities in eCommerce, telecommunications and research & development.

Citation preview

Page 1: Couchbase presentation - by Patrick Heneise

GETTING COMFORTABLE WITH

Patrick Heneise, @PatrickHeneise

Page 2: Couchbase presentation - by Patrick Heneise

About.Me/PatrickHeneiseInformation Architect / Consultant

MSc. in Media Technology, Leiden University, NL

BSc. in Computer Science in Media, Furtwangen University, DE

Certified Software Engineer

♥node.js, , NoSQL

2 years CouchDB/Couchbase experience

Page 3: Couchbase presentation - by Patrick Heneise

AGENDA

Page 4: Couchbase presentation - by Patrick Heneise

Agenda

Introduction to Couchbase

Introduction to Document Design and Best Practices

Introduction to Views (Map, Reduce)

Introduction to memcached

Use Cases

Q&A

Page 5: Couchbase presentation - by Patrick Heneise

Not on the Agenda

Cluster Design

Deployment

Security

Advanced Document Design

Buckets/vBuckets

Page 6: Couchbase presentation - by Patrick Heneise
Page 7: Couchbase presentation - by Patrick Heneise

Couchbase ServerCouchDB

JSON Documents

Indexing and Querying

Map/Reduce

memcached

In-memory key-value store

Sub-millisecond latency

Distributed

Page 8: Couchbase presentation - by Patrick Heneise

Couchbase Server

Auto-Sharding (dynamically add new servers)

Management and monitoring

Data replication with auto-failover

Mobile synchronization

Page 9: Couchbase presentation - by Patrick Heneise

WHY NOSQL?

Page 10: Couchbase presentation - by Patrick Heneise
Page 11: Couchbase presentation - by Patrick Heneise

Why NoSQL?

No schema required

Interactive database engineering

Organic growth

Document/Object related

Page 12: Couchbase presentation - by Patrick Heneise

CouchDB

Page 13: Couchbase presentation - by Patrick Heneise

Use Cases

Information storage

Catalogues

Document-based information

Page 14: Couchbase presentation - by Patrick Heneise

How does it look like?{

“title”: “Barcelona”,“state”: “Catalonia”,“tagline”: “Best place to live in Europe”,“population”: 1621537,“tags”: [

“gaudi”, “sagrada familia”, “beach”, “sun”],“startups”: {

“itnig”: {“tagline”: “Make it happen”,“tags”: [“web development”, “marketing”]

},“desentia”: {

“tagline”: “design to go.”,“tags”: [“design”, “mobile”, “commerce”]

}}

}

Strings

Key Value

NumbersArrays

ObjectsNested Objects

Page 15: Couchbase presentation - by Patrick Heneise

How to interact with data?city.title

city.tags

city.tags[4]

city.startups.desentia.tagline

“Barcelona”

[“gaudi”, “sagrada familia”, “beach”, “sun”]

“gaudi”

“design to go.”

=>

=>

=>

=>

Page 16: Couchbase presentation - by Patrick Heneise

Where’s SELECT?

Map/Reduce Views

JavaScript or Erlang

Spatial Views

Page 17: Couchbase presentation - by Patrick Heneise

Views

function (doc, meta) {

if(doc.jsonType == 'city') {

emit(doc.title, doc.tagline);

}

}

Page 18: Couchbase presentation - by Patrick Heneise

-{- total_rows: 3,- rows:

[-

{- id: "barcelona",- key: "Barcelona",- value: "Best place to live in Europe"

- },-

{- id: "berlin",- key: "Berlin",- value: "Beer and Startups"

- },-

{- id: "london",- key: "London",- value: "Bloody Rainy"

- }- ]

-}

Page 19: Couchbase presentation - by Patrick Heneise

View all tagsfunction (doc, meta) {

if(doc.jsonType == 'city') {

doc.tags.forEach(function(tag) {

emit(tag, doc.title);

});

}

}

Page 20: Couchbase presentation - by Patrick Heneise

-{- total_rows: 12,- rows:

[-

{- id: "barcelona",- key: "beach",- value: "Barcelona"

- },-

{- id: "berlin",- key: "brandenburg gate",- value: "Berlin"

- },-

{- id: "berlin",- key: "cold",- value: "Berlin"

- },-

{- id: "berlin",- key: "DDR",- value: "Berlin"

- },...

Page 21: Couchbase presentation - by Patrick Heneise

JOINSfunction (doc, meta) {

if(doc.jsonType == "startup") {

emit([doc.city, 1], doc.title);

} else if(doc.jsonType == "city") {

emit([meta.id, 0], doc.title);

}

}

Page 22: Couchbase presentation - by Patrick Heneise

["barcelona",0] barcelona "Barcelona"["barcelona",1] desentia "desentia"["barcelona",1] itnig "itnig"["berlin",0] berlin "Berlin"["berlin",1] soundcloud "soundcloud"["london",0] london "London"

Page 23: Couchbase presentation - by Patrick Heneise

MAP/REDUCEfunction (doc, meta) {

if(doc.jsonType == "startup") {

emit(doc.city, 1);

}

}

_count

Page 24: Couchbase presentation - by Patrick Heneise

-{- rows:

[-

{- key: "barcelona",- value: 2

- },-

{- key: "berlin",- value: 1

- }- ]

-}

-{- rows:

[-

{- key: null,- value: 3

- }- ]

-}

group_level 0 group_level 1

Page 25: Couchbase presentation - by Patrick Heneise

memcached

Page 26: Couchbase presentation - by Patrick Heneise

Use Cases

Session Store

Always and fast changing data (user activity)

Stock exchange data

Game states

Page 27: Couchbase presentation - by Patrick Heneise

Pure key-value store

c.set("foo", 1)c.incr("foo") #=> 2c.incr("foo", :delta => 2) #=> 4c.incr("foo", 4) #=> 8c.incr("foo", -1) #=> 7

c.set("foo", "bar")c.set("foo", "bar", :ttl => 30)c["foo"] = "bar"

Page 28: Couchbase presentation - by Patrick Heneise

Examples

user:patrick:id => 1

user:patrick:lastPage => ‘/account’

farmhill:currentPlants => 5

farmhill:nextAvailablePlant => ‘Sunflower’

sess:abc:username => ‘patrick’

global:nextUserId => 15

Page 29: Couchbase presentation - by Patrick Heneise

DEMO

Page 30: Couchbase presentation - by Patrick Heneise
Page 31: Couchbase presentation - by Patrick Heneise

WHERE CAN I USE COUCHBASE?

Page 32: Couchbase presentation - by Patrick Heneise

Use CaseseCommerce Systems

Products, Session, Users, Sales, ...

Q/A Systems

Store a document per user with questions and answers

History Databases

Ancient Books, letters, transcriptions, ...

mCommerce Systems

Products, Location Information

Social Information Systems / Business Intranets

Timesheets, Project information

Wiki / CMS / Blog

Articles, Pages, ...

Gaming Systems

Game states, user data

...

Page 33: Couchbase presentation - by Patrick Heneise

Additional Information

couchbase.com / @couchbase / @jchris / @janl

couchbasemodels.com / @scalabl3

couchbase.com/docs/couchbase-manual-2.0/

couchbase.com/couchconf-berlin - CouchConf Berlin, Oct 30

Page 34: Couchbase presentation - by Patrick Heneise

Q&A

Page 35: Couchbase presentation - by Patrick Heneise

JOIN US ON MEETUP:THE-BARCELONA-COUCHBASE-GROUP

Page 36: Couchbase presentation - by Patrick Heneise

THANK YOU!