Data management for interactive web and mobile applications.




DALE HARVEY




                                                                    1
RELAX




@perezd
What is Couchbase?




       1+1 really does equal 3



                                 3
WHAT IS MEMBASE?




                   4
Deployments Leading Membase




  Leading cloud service (PAAS)    Social game leader – FarmVille,
  provider                        Mafia Wars, Café World
  Over 65,000 hosted              Over 230 million monthly users
  applications                    Membase Server
  Membase Server serving over     is the 500,000 ops-per-second
  1,200 Heroku customers (as of   database behind FarmVille and
  June 10, 2010)                  Café World
                                                                    5
Ad targeting

                            40 milliseconds to come
                            up with an answer.




                        3 profiles, real time campaign
                          statistics




                                      2
                 1
                                    profiles, campaigns
               events

                                                      6
Membase is a distributed database




                             Application user




 Web application server   Web application server   Web application server




                           Membase Servers




                 In the data center                                         On the administrator console



                                                                                                           7
Membase is Simple, Fast, Elastic

               Five minutes or less to a working
               cluster
               • Downloads for Linux and Windows
               • Start with a single node
               • One button press joins nodes to a cluster
               Easy to develop against
               • Just SET and GET – no schema required
               • Drop it in. 10,000+ existing applications
                 already “speak membase” (via memcached)
               • Practically every language and application
                 framework is supported, out of the box
               Easy to manage
               • One-click failover and cluster rebalancing
               • Graphical and programmatic interfaces
               • Configurable alerting



                                                              8
Data is sharded into vBuckets




                                9
Clustering With Membase

                  SET request arrives at          SET acknowledgement
                    KEY’s master server 1   2 returned to application




                           3                                                    3
                                  Listener-Sender

                                  RAM




                                                   membase storage engine
                                                                            4


                                 Disk Disk Disk



                                 Disk Disk Disk


Replica Server 1 for KEY        Master server for KEY                               Replica Server 2 for KEY
                                                                                                          10
Membase is Simple, Fast, Elastic

               Zero-downtime elasticity
               • Spread I/O and data across commodity
                 servers (or VMs)
               • Consistent performance with linear cost
               • Dynamic rebalancing of a live cluster
               All nodes are created equal
               • No special case nodes
               • Any node can replace any other node, online
               • Clone to grow
               Extensible
               • Filtered TAP interface provides hook points
                 for external systems (e.g. full-text search,
                 backup, warehouse)
               • Data bucket – engine API for specialized
                 container types



                                                                11
WHAT IS CouchDB?




                   12
Robust
      JSON
Replication
Map Reduce
 GeoCouch
     HTTP

              13
USE CASES




            14
DOCUMENT STORE
=> GET http://127.0.0.1:5984/mydatabase/
uniqueid
=> PUT http://127.0.0.1:5984/mydatabase/
uniqueid http://127.0.0.1:5984/mydatabase
=> POST
=> DELETE http://127.0.0.1:5984/mydatabase/
uniqueid
{
    “_id”   : “uniqueid”,
    “_rev” : 1234567,
    “title” : “My New Blog Post”,
    “body” : “A quick brown fox .......”,
    “_attachments”: {
      “profile.jpg”: { ...... }
    }
}
                                              15
ROBUST STORAGE ENGINE

Append-Only
Reliable & Concurrent
Hot Backups
Compaction

                          16
INCREMENTAL MAP REDUCE




                         17
PEER-BASED REPLICATION

curl -X POST http://127.0.0.1:5984/_replicate -d
'{
   "source":
     "http://couch.example.com:5984/remote-db",
   "target":
     "local-db"
}'




                                              18
NAILING MOBILE
       • Extremely Robust Storage Engine
          Consumer devices may lose power at any time
       • Lightweight Runtime
          Small install, low memory footprint, easy on
          battery life
       • Offline sync via Replication
          Multi-master synchronization engine
       • GeoSpatial Index
          Mapping and location aware apps
       • HTML5 Application Server
          Easy to add a web view to your mobile data

https://github.com/couchbaselabs/iOS-Couchbase


                                                         19
GEOCOUCH
      CIVICAPI.COM, ETC




Advanced R-Tree Index
                          20
ARCHITECTURE
2.0 Architecture Overview

                           Application



                      Couchbase SDK API


                     MCD                 Couch

                                                 Application Tier



                                                 Elastic Couchbase Server Cluster


         Moxi     Memcached              Couch
                                         Proxy

                  ep_engine

        Cluster
        Manager



                         Couchbase Server


                  vBucket Data       View Data




                                                                                    22
JSON Document Handling

• Per Bucket JSON Document Mode toggle

• JSON Document Mode disabled (or invalid
  JSON)
  – Values are opaque to couch (and in views)
  – Stored as attachments to documents that hold
    metadata
  – Returned values are guaranteed bitwise identical


• JSON Document Mode enabled
  – Values are expected to be valid JSON
  – Stored in document along metadata
                                                       5
  – Returned values may not be bitwise identical but
JSON Document Encodings for memcached
                                                       Couch Document
              Meta Data
      Key:”zdfasf”
      Expiration:43452345            {
      Flags:2352145                       “_id”: ”zdfasf”
                                          “$Expiration”: 43452345,
                                          “$Flags”: 2352145,
                                          “$AttachReason”:”JSON Mode Disabled”, //Other
                Value                reasons “Invalid JSON”, etc.
                                          [“$KeyMangled”: false,] //only included if true
                                           “_attachments”: { “$value”: { … } }
     0x87632f98,0xa76b876d, …!       }




                                                       Couch Document
             Meta Data
      Key:”zdfasf”
      Expiration:43452345
      Flags:2352145              {
                                         “_id”: ”zdfasf”
                                         “$Expiration”: 43452345,
                                         “$Flags”: 2352145,
           JSON Document                 [“$KeyMangled”: false,] //only included if true
                                          “foo”: ”bar”
       {                         }
              “foo”: ”bar”
       }




                                                                                            24
Scatter Gather Map Reduce




• Get next answer from local vBuckets and from
  child nodes to select the next result for a node
• Result includes info on number of vBuckets not
  included
  – Timeouts, Incorrect Design Doc version, etc   8
Scatter Gather Example




                         9
Scatter Gather Example




                         10
Scatter Gather Example




                         11
Scatter Gather Example




                         12
Scatter Gather Example




                         13
Scatter Gather Example




                         14
Scatter Gather Example




                         15
Scatter Gather Example




                         16
Scatter Gather Example




                         17
Scatter Gather Example




                         18
Scatter Gather Example




                         19
Q&A




DALE HARVEY
DALE@COUCHBASE.COM
@DALEHARVEY




                           37

Couchdb + Membase = Couchbase

  • 1.
    Data management forinteractive web and mobile applications. DALE HARVEY 1
  • 2.
  • 3.
    What is Couchbase? 1+1 really does equal 3 3
  • 4.
  • 5.
    Deployments Leading Membase Leading cloud service (PAAS) Social game leader – FarmVille, provider Mafia Wars, Café World Over 65,000 hosted Over 230 million monthly users applications Membase Server Membase Server serving over is the 500,000 ops-per-second 1,200 Heroku customers (as of database behind FarmVille and June 10, 2010) Café World 5
  • 6.
    Ad targeting 40 milliseconds to come up with an answer. 3 profiles, real time campaign statistics 2 1 profiles, campaigns events 6
  • 7.
    Membase is adistributed database Application user Web application server Web application server Web application server Membase Servers In the data center On the administrator console 7
  • 8.
    Membase is Simple,Fast, Elastic Five minutes or less to a working cluster • Downloads for Linux and Windows • Start with a single node • One button press joins nodes to a cluster Easy to develop against • Just SET and GET – no schema required • Drop it in. 10,000+ existing applications already “speak membase” (via memcached) • Practically every language and application framework is supported, out of the box Easy to manage • One-click failover and cluster rebalancing • Graphical and programmatic interfaces • Configurable alerting 8
  • 9.
    Data is shardedinto vBuckets 9
  • 10.
    Clustering With Membase SET request arrives at SET acknowledgement KEY’s master server 1 2 returned to application 3 3 Listener-Sender RAM membase storage engine 4 Disk Disk Disk Disk Disk Disk Replica Server 1 for KEY Master server for KEY Replica Server 2 for KEY 10
  • 11.
    Membase is Simple,Fast, Elastic Zero-downtime elasticity • Spread I/O and data across commodity servers (or VMs) • Consistent performance with linear cost • Dynamic rebalancing of a live cluster All nodes are created equal • No special case nodes • Any node can replace any other node, online • Clone to grow Extensible • Filtered TAP interface provides hook points for external systems (e.g. full-text search, backup, warehouse) • Data bucket – engine API for specialized container types 11
  • 12.
  • 13.
    Robust JSON Replication Map Reduce GeoCouch HTTP 13
  • 14.
  • 15.
    DOCUMENT STORE => GEThttp://127.0.0.1:5984/mydatabase/ uniqueid => PUT http://127.0.0.1:5984/mydatabase/ uniqueid http://127.0.0.1:5984/mydatabase => POST => DELETE http://127.0.0.1:5984/mydatabase/ uniqueid { “_id” : “uniqueid”, “_rev” : 1234567, “title” : “My New Blog Post”, “body” : “A quick brown fox .......”, “_attachments”: { “profile.jpg”: { ...... } } } 15
  • 16.
    ROBUST STORAGE ENGINE Append-Only Reliable& Concurrent Hot Backups Compaction 16
  • 17.
  • 18.
    PEER-BASED REPLICATION curl -XPOST http://127.0.0.1:5984/_replicate -d '{ "source": "http://couch.example.com:5984/remote-db", "target": "local-db" }' 18
  • 19.
    NAILING MOBILE • Extremely Robust Storage Engine Consumer devices may lose power at any time • Lightweight Runtime Small install, low memory footprint, easy on battery life • Offline sync via Replication Multi-master synchronization engine • GeoSpatial Index Mapping and location aware apps • HTML5 Application Server Easy to add a web view to your mobile data https://github.com/couchbaselabs/iOS-Couchbase 19
  • 20.
    GEOCOUCH CIVICAPI.COM, ETC Advanced R-Tree Index 20
  • 21.
  • 22.
    2.0 Architecture Overview Application Couchbase SDK API MCD Couch Application Tier Elastic Couchbase Server Cluster Moxi Memcached Couch Proxy ep_engine Cluster Manager Couchbase Server vBucket Data View Data 22
  • 23.
    JSON Document Handling •Per Bucket JSON Document Mode toggle • JSON Document Mode disabled (or invalid JSON) – Values are opaque to couch (and in views) – Stored as attachments to documents that hold metadata – Returned values are guaranteed bitwise identical • JSON Document Mode enabled – Values are expected to be valid JSON – Stored in document along metadata 5 – Returned values may not be bitwise identical but
  • 24.
    JSON Document Encodingsfor memcached Couch Document Meta Data Key:”zdfasf” Expiration:43452345 { Flags:2352145 “_id”: ”zdfasf” “$Expiration”: 43452345, “$Flags”: 2352145, “$AttachReason”:”JSON Mode Disabled”, //Other Value reasons “Invalid JSON”, etc. [“$KeyMangled”: false,] //only included if true “_attachments”: { “$value”: { … } } 0x87632f98,0xa76b876d, …! } Couch Document Meta Data Key:”zdfasf” Expiration:43452345 Flags:2352145 { “_id”: ”zdfasf” “$Expiration”: 43452345, “$Flags”: 2352145, JSON Document [“$KeyMangled”: false,] //only included if true “foo”: ”bar” { } “foo”: ”bar” } 24
  • 25.
    Scatter Gather MapReduce • Get next answer from local vBuckets and from child nodes to select the next result for a node • Result includes info on number of vBuckets not included – Timeouts, Incorrect Design Doc version, etc 8
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.