41

Webinar - Couchbase in Action - Real-World App Demo

Embed Size (px)

DESCRIPTION

Learn more about real-world applications of Couchbase Server NoSQL document database.

Citation preview

Page 1: Webinar - Couchbase in Action - Real-World App Demo
Page 2: Webinar - Couchbase in Action - Real-World App Demo

Technical)Evangelist)/)Scalability)Sherpa

twitter:)@scalabl3email:)[email protected]

Jasdeep)Jaitla

Building)Apps)with)Couchbase

WIFI:%HeavyBitGuestp/w:%guestbit

Page 3: Webinar - Couchbase in Action - Real-World App Demo

Jasdeep'JaitlaTechnical)Evangelist

@[email protected]

Give'me'a'shout'out'with'@couchbase'@scalabl3!

Page 4: Webinar - Couchbase in Action - Real-World App Demo

Why$I$found$Couchbase...

We wanted high performance and near real-time interactions, PHP wasn’t cutting it.

I rebuilt the whole app using Ruby/Rails,Backbone.js, Pubnub, Couchbase and Neo4J.

We didn’t get funding so I left and startedworking for Couchbase.

Page 5: Webinar - Couchbase in Action - Real-World App Demo

Couchbase*Server*Core*Principles

EasyScalability

Consistent/HighPerformance

Always/On24x365

Grow*cluster*withoutapplication*changes,*withoutdowntime*with*a*single*click

Consistent*sub;millisecond*read*and*write*response*times*with*consistent*high*throughput

No*downtime*for*softwareupgrades,*hardwaremaintenance,*etc.

Flexible/DataModel

JSON*document*model*with*nofixed*schema.

JSONJSONJSON

JSONJSON

PERFORMANCE

Page 6: Webinar - Couchbase in Action - Real-World App Demo

UNDERSTAND

Page 7: Webinar - Couchbase in Action - Real-World App Demo

Applications+Have+Many+Dimensions

Inception.

Why’d he put that there?

Page 8: Webinar - Couchbase in Action - Real-World App Demo

Our$Developer$Brain$isn’t...

The$Modernist$Mindlate%19th%)%early%20th%Centuries

Page 9: Webinar - Couchbase in Action - Real-World App Demo

Our$Real$Developer$Brain

Page 10: Webinar - Couchbase in Action - Real-World App Demo

In#Fact,#the#World#Is#More#Like#this:

The#Postmodern#Mindmid$20th$Century$/$Now?

Page 11: Webinar - Couchbase in Action - Real-World App Demo

The$Post)Postmodern$Mind21st%century%,%Now.

bigdata

Mmm,$data.

Page 12: Webinar - Couchbase in Action - Real-World App Demo

bigdata

..."this"makes"sense"...

Users%“do”%these%actions>>"methods

Users%“have”properties/state>>"instance"variables

•4

4

Page 13: Webinar - Couchbase in Action - Real-World App Demo

..."this"makes"sense"...

Page 14: Webinar - Couchbase in Action - Real-World App Demo

Relational)Modeling

In#Memory,#your#objects#have#an#implicit#data#structure#

An)object)is)a)collection)of)data)structures

These)data)Structures)are)rich:

Keys)(variable)names)

Simple)Single)Values)(string,)integer,)float))

RDBMS#handles#Simple#Single#Values#as#Columns

BB

••

Page 15: Webinar - Couchbase in Action - Real-World App Demo

Relational)Modeling

In#Memory,#your#objects#have#an#implicit#data#structure

Complex)Collection)Values)(arrays,)dictionary/hashes)

More)Complex)Values:)Collections)of)Objects

Structures)can)be)nested)within)Structures

RDBMS#Can’t#Map#Complex#Collection#Values#SIMPLY

Most#commonly#it’s#via#a#JOIN#with#

1H1#or#1..n#type#foreign_key#relationship

•••

Page 16: Webinar - Couchbase in Action - Real-World App Demo

Relational)Modeling

Ends)up)with)a)table)sprawl)that)makesJOINs)very)slow)at)scale.

Page 17: Webinar - Couchbase in Action - Real-World App Demo

Aggregate'View'of'Data

http://martinfowler.com/bliki/AggregateOrientedDatabase.html

Page 18: Webinar - Couchbase in Action - Real-World App Demo

Store&and&Retrieve&Aggregates

Easier&to&DistributeDataMore&FlexibilityReduced&Latency

••

order::1001{uid:&ji22jd,customer:&Ann,line_items:&[&{&sku:&0321293533,&quan:&3,&unit_price:&48.0&},{&sku:&0321601912,&quan:&1,&unit_price:&39.0&},{&sku:&0131495054,&quan:&1,&unit_price:&51.0&}&],payment:&{&type:&Amex,&expiry:&04/2001,&last5:&12345&}}

Page 19: Webinar - Couchbase in Action - Real-World App Demo

JSON%supports%direct%relationship%of%In%Memory%Data%Structures%to%Data%Storage

No%Impedance%Mismatch

Page 20: Webinar - Couchbase in Action - Real-World App Demo

Objects(Serialized(to(JSON(and(Backstring uid

string firstname

string lastname

int age

array favorite_colors

string email

User%Object u::[email protected]{“uid”:(123456,“firstname”:(“jasdeep”,“lastname”:(“Jaitla”,“age”:(22,“favorite_colors”:([“blue”,(“black”],“email”:(“[email protected]”}

string uid

string firstname

string lastname

int age

array favorite_colors

string email

User%Object u::[email protected]{“uid”:(123456,“firstname”:(“jasdeep”,“lastname”:(“Jaitla”,“age”:(22,“favorite_colors”:([“blue”,(“black”],“email”:(“[email protected]”}

set()

get()

Page 21: Webinar - Couchbase in Action - Real-World App Demo

JSON%Document%Structuremeta{“id”:%“u::[email protected]”,“rev”:%“1>0002bce0000000000”,“flags”:%0,“expiration”:%0,“type”:%“json”}

document{“uid”:%123456,“firstname”:%“jasdeep”,“lastname”:%“Jaitla”,“age”:%22,“favorite_colors”:%[“blue”,%“black”],“email”:%“[email protected]”}

Meta6InformationIncluding%Key

All%Keys%Unique%andKept%in%RAM

Document6Value

Most%Recent%In%RamAnd%Persisted%To%Disk

Page 22: Webinar - Couchbase in Action - Real-World App Demo

the$best$products$don’t$just$solve$a$need.

Page 23: Webinar - Couchbase in Action - Real-World App Demo

the$best$products$create$and$solve$a$need.

Jean1Baptiste$Say$(176711832)Say’s$Law:$“Supply'creates'its'own'Demand”

Keynesian$Economics

Page 24: Webinar - Couchbase in Action - Real-World App Demo

What%happens%when%you%do%both%well?

Scale.'Acquisition.'IPO.

Page 25: Webinar - Couchbase in Action - Real-World App Demo

SCALE

Page 26: Webinar - Couchbase in Action - Real-World App Demo

DrawSomething:/Non1Linear/Growth

191715131197533/12826242220181614121082/6

Draw%Something%by%OMGPOPDaily&Active&Users&(millions)

21

2

4

6

8

10

12

14

16

By/March/19,/there/were/

30M%downloads3,000+%drawings/second

2%Billion%Drawings3.3+%Terabytes

Page 27: Webinar - Couchbase in Action - Real-World App Demo

Apps$in$1995

Client'(Browsers)' App'Server' SQL'Database'Server'

Double$your$salary$by$making$a$“dynamic”$website

Page 28: Webinar - Couchbase in Action - Real-World App Demo

Late%1990’s

Client'(Browsers)' App'Servers' SQL'Database'Server'

Page 29: Webinar - Couchbase in Action - Real-World App Demo

Early&2000’s

Memcached(Client((Browsers)( App(Servers( SQL(Database(Server(

Page 30: Webinar - Couchbase in Action - Real-World App Demo

Mid$2000’sApp#Servers# Memcached#

(Membase)#

SQL#Database#Clusters#

Page 31: Webinar - Couchbase in Action - Real-World App Demo

8"

App"Servers"

API"Servers"

Couchbase"Server"Cluster"

Couchbase*Simplifies

Page 32: Webinar - Couchbase in Action - Real-World App Demo

Client'SDKs

Couchbase'Client

App#Server

make'conn

ection

receive'top

ologyCouchbaseTopologyUpdate

Page 33: Webinar - Couchbase in Action - Real-World App Demo

Official'SDKs

Community'SDKs

www.couchbase.com/develop

PythonRuby

Go Clojure

Page 34: Webinar - Couchbase in Action - Real-World App Demo

REPOWALL.COM

Page 35: Webinar - Couchbase in Action - Real-World App Demo

DEMO

Page 36: Webinar - Couchbase in Action - Real-World App Demo

User%Documents1.#Primary#User#Document

u::{github_id}%%%%%%%%%%%%%%%%%%%%%%%%%%%=>%%u::1718606

2.#Reference#Document

u::{github_username}%%%%%%%%%%%%%%%%=>%u::scalabl3

3.#Repo#List#Document

r::{github_id}%%%%%%%%%%%%%%%%%%%%%%%%=>%r::1718606

4.%Repo#List#Raw#JSON

r::{github_id}::github%%%%%%%%%%%%%%%%=>%r::1718606::github

Page 37: Webinar - Couchbase in Action - Real-World App Demo

User%Document{""doctype"":""user",""last_retrieve"":"1363171793,""is_registered"":"true,""superuser"":"false,""last_retrieve_repos"":"1363171977,""github_id"":"1718606,""github_username"":""scalabl3",""num_followers"":"14,""num_following"":"50,""url"":""https://github.com/scalabl3",""avatar"":"https://secure.gravatar.com/avatar/56665ca94bdd4ad5d41b239e07fa823c?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2FgravatarJuserJ420.png",""gravatar_id"":""56665ca94bdd4ad5d41b239e07fa823c",""num_repos"":"57,""num_repos_private"":"J1,""user_type"":""User",""email"":""[email protected]",""bio"":"null,""proficiencies"":"null,""github_json"":"{"..."""""}"""}"},""github_access_token"":""xxx",""pubnub_channel"":""dc7580f1b474"}

Page 38: Webinar - Couchbase in Action - Real-World App Demo

User%Repo%List{""doctype"":""repos",""github_id"":"1718606,""github_username"":""scalabl3",""language_dist"":"{"unknown":""["Unknown",7],"shell":""["Shell",1],"java":""["Java",2],"actionscript":""["ActionScript",1],"javascript":""["JavaScript",3],"c":""["C",3],"python":""["Python",2],"go":""["Go",5],"c#":""["C#",1],"clojure":""["Clojure",3],"ruby":""["Ruby",28],"objective9c":""["ObjectiveMC",1]},""repos"":"{""""8737681"":"{""""""repo_id"":"8737681,""""""name"":""ironworkerMlibcouchbase",""""""full_name"":""scalabl3/ironworkerMlibcouchbase",""""""updated_at"":"1363120145,""""""created_at"":"1363120145,""""""pushed_at"":"1363119688,""""""is_fork"":"true,""""""language"":"null,""""""forks_count"":"0,""""""watchers_count"":"0,""""""description"":""",""""""is_private"":"false,""""""owner"":""scalabl3",

Page 39: Webinar - Couchbase in Action - Real-World App Demo

User%Instance%Vars%&%Save%Method

class%User%<%ModelBase%%%%fattr%:doctype,%:default%=>%self.to_s.downcase%fattr%:last_retrieve,%:default%=>%Time.now.getutc.to_i%fattr%:is_registered,%:default%=>%false%fattr%:superuser,%:default%=>%false

%fattr%:last_retrieve_repos,%:default%=>%nil%fattr%:github_id,%:github_username,%:num_followers,%:num_following,%:url,:avatar,%:gravatar_id,%:num_repos,%:num_repos_private,%:user_type,%:email,%:bio,%:proficiencies,:github_json,%:github_access_token,%:pubnub_channel

#%update%with%new%last_retrieve_reposc.replace(“u::1718606”,3self.to_hash)

Page 40: Webinar - Couchbase in Action - Real-World App Demo

Learn&More&Patterns

Couchbase*&*RailsCouchbaseOnRails.com

Couchbase*ModelsCouchbaseModels.com

Page 41: Webinar - Couchbase in Action - Real-World App Demo

Questions?

Jasdeep'JaitlaTechnical/Evangelist

@[email protected]

Give'me'a'shout'out'with'@couchbase'@scalabl3!