SlideShare a Scribd company logo
Introduction to
Riak & Ripple
      Sean Cribbs
basho Developer Advocate
Introduction to
Riak & Ripple
      Sean Cribbs
basho Developer Advocate

                    Rubyist, Evangelist,
                     Support Monkey
Riak @10,000 ft.
Riak @10,000 ft.
• Amazon Dynamo-inspired
  replicated, distributed,
  fault-tolerant, masterless,
  scalable, operations-friendly
Riak @10,000 ft.
• Amazon Dynamo-inspired
  replicated, distributed,
  fault-tolerant, masterless,
  scalable, operations-friendly

• Key-Value / Document
Riak @10,000 ft.
• Amazon Dynamo-inspired
  replicated, distributed,
  fault-tolerant, masterless,
  scalable, operations-friendly

• Key-Value / Document
• Schema-less, content-agnostic
Riak @10,000 ft.
• Amazon Dynamo-inspired
  replicated, distributed,
  fault-tolerant, masterless,
  scalable, operations-friendly

• Key-Value / Document
• Schema-less, content-agnostic
• Web-friendly
  HTTP, JSON, Javascript
Dynamo-like
 Scalability
Dynamo-like
       Scalability
• To get...
Dynamo-like
      Scalability
• To get...
 • more storage,
Dynamo-like
      Scalability
• To get...
 • more storage,
 • more throughput,
Dynamo-like
      Scalability
• To get...
 • more storage,
 • more throughput,
 • lower latency...
Dynamo-like
       Scalability
• To get...
 • more storage,
 • more throughput,
 • lower latency...
• ...add more machines.
  aka horizontal & linear
Key-Value++
Key-Value++
• Data objects are identified by keys,
  and have metadata
Key-Value++
• Data objects are identified by keys,
  and have metadata

• Keys are grouped in buckets
Key-Value++
• Data objects are identified by keys,
  and have metadata

• Keys are grouped in buckets
• Links enable lightweight
  relationships
Key-Value++
• Data objects are identified by keys,
  and have metadata

• Keys are grouped in buckets
• Links enable lightweight
  relationships

• Query with MapReduce
Sans-Schema
Sans-Schema
• Buckets created on the fly
Sans-Schema
• Buckets created on the fly
• Values are opaque
Sans-Schema
• Buckets created on the fly
• Values are opaque
•Content-Type matters
Sans-Schema
• Buckets created on the fly
• Values are opaque
•Content-Type matters
•The application defines the
 semantics:
 more flexibility, more responsibility
Web-Friendly
Web-Friendly
•HTTP is primary interface
Web-Friendly
•HTTP is primary interface
•JSON is used for structured data
Web-Friendly
•HTTP is primary interface
•JSON is used for structured data
•Javascript is used for
  MapReduce functions
Web-Friendly
•HTTP is primary interface
•JSON is used for structured data
•Javascript is used for
  MapReduce functions

•Plays well with Varnish, Squid,
  HAProxy, F5, etc.
Web-Friendly
•HTTP is primary interface
•JSON is used for structured data
•Javascript is used for
  MapReduce functions

•Plays well with Varnish, Squid,
  HAProxy, F5, etc.
  [see also Webmachine]
Use Cases
Use Cases
•Document storage
 (sparse structure)
Use Cases
•Document storage
 (sparse structure)

•Distributed file storage
 (small size, large soon)
Use Cases
•Document storage
 (sparse structure)

•Distributed file storage
 (small size, large soon)

•Session storage
Use Cases
•Document storage
 (sparse structure)

•Distributed file storage
 (small size, large soon)

•Session storage
•Distributed cache
Use Cases
•Document storage
 (sparse structure)

•Distributed file storage
 (small size, large soon)

•Session storage
•Distributed cache
• Browser-only/Mobile Apps
Getting Started
Getting Started
• Download a package from
 http://downloads.basho.com
Getting Started
• Download a package from
  http://downloads.basho.com

• Set the node name, IPs
Getting Started
• Download a package from
  http://downloads.basho.com

• Set the node name, IPs
• Start up the node
Getting Started
• Download a package from
  http://downloads.basho.com

• Set the node name, IPs
• Start up the node
• Join a cluster
Getting Started
• Download a package from
  http://downloads.basho.com

• Set the node name, IPs
• Start up the node
• Join a cluster
• Start storing/retrieving values
Riak in Ruby
Riak in Ruby
• Three gems
Riak in Ruby
• Three gems
 • riak-client (basic ops)
Riak in Ruby
• Three gems
 • riak-client (basic ops)
 • ripple (ODM)
Riak in Ruby
• Three gems
 • riak-client (basic ops)
 • ripple (ODM)
 • riak-sessions
   (Rack/Rails session stores)
Riak in Ruby
• Three gems
 • riak-client (basic ops)
 • ripple (ODM)
 • riak-sessions
   (Rack/Rails session stores)

• All HTTP - Protobuffs coming
require ‘riak’
require ‘riak’
• Make a client object
 client = Riak::Client.new
require ‘riak’
• Make a client object
 client = Riak::Client.new

• Get a bucket
 bucket = client.bucket(‘foo’) # Riak::Bucket
require ‘riak’
• Make a client object
 client = Riak::Client.new

• Get a bucket
 bucket = client.bucket(‘foo’) # Riak::Bucket

• Get an object from the bucket
 obj = bucket.get(‘bar’) # Riak::RObject
require ‘riak’
• Make a client object
 client = Riak::Client.new

• Get a bucket
 bucket = client.bucket(‘foo’) # Riak::Bucket

• Get an object from the bucket
 obj = bucket.get(‘bar’) # Riak::RObject

• Initialize a new object
 obj = bucket.new(‘baz’)
Riak::RObject
Riak::RObject
•Get/set object key
 obj.key = “bar”
Riak::RObject
•Get/set object key
 obj.key = “bar”

•Get/set content-type
 obj.content_type = ‘application/json’
Riak::RObject
•Get/set object key
 obj.key = “bar”

•Get/set content-type
 obj.content_type = ‘application/json’

•Get/set the object body data
 obj.data = {“name” => “Sean”}
Riak::RObject
•Get/set object key
 obj.key = “bar”

•Get/set content-type
 obj.content_type = ‘application/json’

•Get/set the object body data
 obj.data = {“name” => “Sean”}

•Store the object
 obj.store
More RObject
More RObject
•Get object’s bucket
 obj.bucket
More RObject
•Get object’s bucket
 obj.bucket

•Delete the object
 obj.delete # freezes the object
More RObject
•Get object’s bucket
  obj.bucket

•Delete the object
  obj.delete # freezes the object

•Detect/extract siblings (more later)
  obj.conflict? && obj.siblings
  # Array<RObject>
More RObject
•Get object’s bucket
  obj.bucket

•Delete the object
  obj.delete # freezes the object

•Detect/extract siblings (more later)
  obj.conflict? && obj.siblings
  # Array<RObject>

•Follow/traverse links (more later)
  obj.walk(:tag => “friend”)
Riak::Bucket
Riak::Bucket
•Set the replication factor
  bucket.n_val = 5
Riak::Bucket
•Set the replication factor
  bucket.n_val = 5

•Set default request quorums
  bucket.r = 3 # w,dw,rw
   # number or one/all/quorum
Riak::Bucket
•Set the replication factor
  bucket.n_val = 5

•Set default request quorums
  bucket.r = 3 # w,dw,rw
   # number or one/all/quorum

•List keys
  bucket.keys # pass block to stream
Riak::Bucket
•Set the replication factor
  bucket.n_val = 5

•Set default request quorums
  bucket.r = 3 # w,dw,rw
   # number or one/all/quorum

•List keys
  bucket.keys # pass block to stream

•Set consistency flag (allow sibling generation)
  obj.allow_mult = true
Links: Lightweight
Relationships
Link Header


Link: </riak/demo/test1>; riaktag=”userinfo”
Link Header

          bucket

Link: </riak/demo/test1>; riaktag=”userinfo”
Link Header

          bucket

Link: </riak/demo/test1>; riaktag=”userinfo”


                  key
Link Header

          bucket                       tag

Link: </riak/demo/test1>; riaktag=”userinfo”


                  key
Links in Ruby API
Links in Ruby API
• Create a link
  Riak::Link.new(“/riak/bucket/key”,
            “tag”)
Links in Ruby API
• Create a link
  Riak::Link.new(“/riak/bucket/key”,
            “tag”)

• Read an#object’s links
  obj.links Set<Riak::Link>
Links in Ruby API
• Create a link
  Riak::Link.new(“/riak/bucket/key”,
              “tag”)

• Read an#object’s links
  obj.links Set<Riak::Link>

• Convert<< obj2.to_link(“next”)
  obj.links
            an object to a link

  obj.store
Link-Walking
Link-Walking
• Asks Riak to traverse a sequence of
  links via special URL
Link-Walking
• Asks Riak to traverse a sequence of
  links via special URL

• Filter by bucket/tag
Link-Walking
• Asks Riak to traverse a sequence of
  links via special URL

• Filter by bucket/tag
• Can return results from
  intermediate traversals
Link-Walking
• Asks Riak to traverse a sequence of
  links via special URL

• Filter by bucket/tag
• Can return results from
  intermediate traversals

• Response is nested multipart/mixed
  (riak-client handles this for you)
L/W Example
L/W Example
GET /riak/demo/test1/_,friend,1

Start at demo/test1, follow all links
tagged “friend” and return the objects

obj = client[‘demo’][‘test1’]
obj.walk(:tag => “friend”,:keep => true)
L/W Example
GET /riak/demo/test1/_,friend,1

Start at demo/test1, follow all links
tagged “friend” and return the objects

obj = client[‘demo’][‘test1’]
obj.walk(:tag => “friend”,:keep => true)
L/W Example
L/W Example
GET /riak/demo/test1/_,_,_/_,_,1

Start at demo/test1, follow all links,
follow all links from those, return
everything from the last set

obj.walk({},{:keep => true})
Map-Reduce
list of keys




Map-Reduce
list of keys



map    map       map        map   map




      Map-Reduce
list of keys



map    map       map        map   map




                reduce




      Map-Reduce
list of keys



map    map       map        map   map




                reduce



               results



      Map-Reduce
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];
}
Map
                        in Javascript

         Riak object

function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];
}
Map
                            in Javascript

         Riak object

function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
                         {
        if(object[field] != arg[field]) {
            return [];    bucket:”foo”,
        }                 key:”bar”,
    }                     vclock:”...”,
    return [object];
}                         values:[
                            {metadata:{...},
                             data:”....”}
                        ]
                       }
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];
}
Map
                        in Javascript
                  Key-specific
                     data

function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];
}
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];
}
Map
                        in Javascript
                             Phase-
                           specific data
function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];
}
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];
}
Map
                       in Javascript


function(value, keyData, arg) {             Parse JSON data
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];
}
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];
}
Map
                         in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }                               Check field equality
    return [object];
}
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];
}
Map
                         in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];           Return nothing if unequal
        }
    }
    return [object];
}
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];
}
Map
                          in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];         Return the object if all equal
}
Map
                        in Javascript


function(value, keyData, arg) {
    var object = Riak.mapValuesJson(value)[0];
    for(field in arg) {
        if(object[field] != arg[field]) {
            return [];
        }
    }
    return [object];
}
Reduce
                         in Javascript




function(values,arg) {
    return values.sort(function(a,b){
      return a[arg] - b[arg];
    });
}
Reduce
                         in Javascript


         Map results

function(values,arg) {
    return values.sort(function(a,b){
      return a[arg] - b[arg];
    });
}
Reduce
                         in Javascript




function(values,arg) {
    return values.sort(function(a,b){
      return a[arg] - b[arg];
    });
}
Reduce
                         in Javascript


                  Phase-
                specific data

function(values,arg) {
    return values.sort(function(a,b){
      return a[arg] - b[arg];
    });
}
Reduce
                         in Javascript




function(values,arg) {
    return values.sort(function(a,b){
      return a[arg] - b[arg];
    });
}
Reduce
                        in Javascript




function(values,arg) {
    return values.sort(function(a,b){
      return a[arg] - b[arg];
    });                        Custom sort on
}
Reduce
                         in Javascript




function(values,arg) {
    return values.sort(function(a,b){
      return a[arg] - b[arg];
    });
}
Reduce
                         in Javascript




function(values,arg) {
    return values.sort(function(a,b){
      return a[arg] - b[arg];
    });
}


  Reduce potentially called multiple times!!
Example Query
Example Query
{“inputs”: “goog”,
“query”: [{“map”:{“language”:”javascript”,
            “name”: “App.findHighGreater”,
            “arg”: 600.0,
            “keep”: false},
       {“reduce”:{“language”:”javascript”,
              “name”: “Riak.reduceMax”,
              “keep”: true}]}
Example Query
{“inputs”: “goog”,
 “query”: [{“map”:{“language”:”javascript”,
             “name”: “App.findHighGreater”,
             “arg”: 600.0,
             “keep”: false},
       {“reduce”:{“language”:”javascript”,
               “name”: “Riak.reduceMax”,
               “keep”: true}]}

Riak::MapReduce.new(c).add(‘goog’).
       map(‘App.findHighGreater’, :arg => 600.0).
       reduce(“Riak.reduceMax”, :keep => true).run
Built-in Functions
Built-in Functions
• Riak.mapValues
Built-in Functions
• Riak.mapValues
• Riak.mapValuesJson
Built-in Functions
• Riak.mapValues
• Riak.mapValuesJson
• Riak.mapByFields
Built-in Functions
• Riak.mapValues
• Riak.mapValuesJson
• Riak.mapByFields
• Riak.reduceSum
Built-in Functions
• Riak.mapValues
• Riak.mapValuesJson
• Riak.mapByFields
• Riak.reduceSum
• Riak.reduceSort
Built-in Functions
• Riak.mapValues
• Riak.mapValuesJson
• Riak.mapByFields
• Riak.reduceSum
• Riak.reduceSort
• Riak.reduceMin/reduceMax
Ripple - ODM
Document Models
class Person
 include Ripple::Document

 property :name, String, :presence => true
 many :addresses
 many :friends, :class => Person
end

class Address
 include Ripple::EmbeddedDocument

 property :street, String
end
Rails Setup
Rails Setup

# Gemfile
gem 'curb'    # Faster HTTP
gem 'yajl-ruby' # Faster JSON
gem 'ripple'
Rails Setup

# Gemfile
gem 'curb'    # Faster HTTP
gem 'yajl-ruby' # Faster JSON
gem 'ripple'
Rails Setup

# Gemfile
gem 'curb'    # Faster HTTP
gem 'yajl-ruby' # Faster JSON
gem 'ripple'


$ gem install curb yajl-ruby ripple
Rails Setup (cont.)
Rails Setup (cont.)
# config/ripple.yml
development:
 host: 127.0.0.1
 port: 8098
Rails Setup (cont.)
# config/ripple.yml
development:
 host: 127.0.0.1
 port: 8098


# config/application.rb
require 'ripple/railtie'
Ripple Roadmap
Ripple Roadmap
• Testing server (edge on Github)
Ripple Roadmap
• Testing server (edge on Github)
• Protocol Buffers support
Ripple Roadmap
• Testing server (edge on Github)
• Protocol Buffers support
• Streaming MapReduce
Ripple Roadmap
• Testing server (edge on Github)
• Protocol Buffers support
• Streaming MapReduce
• Ripple-specific built-ins
Ripple Roadmap
• Testing server (edge on Github)
• Protocol Buffers support
• Streaming MapReduce
• Ripple-specific built-ins
• Better ActionView support
  (form_for)
Happy Fun
Demo Time
Plug




basho
Plug
        Interested in learning about support,
        consulting, or Enterprise features?




basho
Plug
        Interested in learning about support,
        consulting, or Enterprise features?
        Email info@basho.com or go to
        http://www.basho.com/
        contact.html to talk with us.




basho
Plug
        Interested in learning about support,
        consulting, or Enterprise features?
        Email info@basho.com or go to
        http://www.basho.com/
        contact.html to talk with us.




basho
Plug
        Interested in learning about support,
        consulting, or Enterprise features?
        Email info@basho.com or go to
        http://www.basho.com/
        contact.html to talk with us.

                     www.basho.com

             sean@basho.com
               @seancribbs
basho
Questions

More Related Content

KEY
Embrace NoSQL and Eventual Consistency with Ripple
KEY
Riak with node.js
KEY
Introduction to Riak - Red Dirt Ruby Conf Training
PPTX
Coding with Riak (from Velocity 2015)
PDF
Riak 2.0 : For Beginners, and Everyone Else
KEY
Riak Training Session — Surge 2011
PDF
Relational Databases to Riak
KEY
PHP API
Embrace NoSQL and Eventual Consistency with Ripple
Riak with node.js
Introduction to Riak - Red Dirt Ruby Conf Training
Coding with Riak (from Velocity 2015)
Riak 2.0 : For Beginners, and Everyone Else
Riak Training Session — Surge 2011
Relational Databases to Riak
PHP API

What's hot (18)

PDF
Riak Intro at Munich Node.js
KEY
Couchdb: No SQL? No driver? No problem
PDF
Icinga 2009 at OSMC
PPTX
Oak Lucene Indexes
PDF
OSDC 2014: Sebastian Harl - SysDB the system management and inventory collect...
PPTX
Full stack development with node and NoSQL - All Things Open - October 2017
PDF
Assetic (OSCON)
PPTX
HiveServer2
PDF
Django - 次の一歩 gumiStudy#3
PDF
Apache Spark and DataStax Enablement
PDF
Elasticsearch for SQL Users
PDF
The effective use of Django ORM
PDF
Harnessing the power of Nutch with Scala
KEY
Introducing Riak
PPTX
Apache Kite
PDF
LA Cassandra Day 2015 - Cassandra for developers
PDF
Spark Programming
PDF
Workshop: Learning Elasticsearch
Riak Intro at Munich Node.js
Couchdb: No SQL? No driver? No problem
Icinga 2009 at OSMC
Oak Lucene Indexes
OSDC 2014: Sebastian Harl - SysDB the system management and inventory collect...
Full stack development with node and NoSQL - All Things Open - October 2017
Assetic (OSCON)
HiveServer2
Django - 次の一歩 gumiStudy#3
Apache Spark and DataStax Enablement
Elasticsearch for SQL Users
The effective use of Django ORM
Harnessing the power of Nutch with Scala
Introducing Riak
Apache Kite
LA Cassandra Day 2015 - Cassandra for developers
Spark Programming
Workshop: Learning Elasticsearch
Ad

Viewers also liked (20)

PDF
IBM-BLOCKCHAIN-DECK
PPTX
T-mining presentation at BlockChain Vlaanderen
PDF
Smart Contracts and Identity
PDF
Ripple Labs: Values, Purpose, Strategy 2014
PDF
Open & Private Blockchains at CSCMP Benelux Supply Chain Event
PDF
Build Secure IoT Solutions Using... Blockchain - Geeta Chauhan
PPTX
Conceptualizing Smart Contracts
PPT
Smart Gateways, Blockchain and the Internet of Things (Charalampos Doukas-Cre...
PDF
Yang Ming Struggling to Keep Up
PPTX
Secure IoT with Blockchain: Fad or Reality? [BOF5490]
PPT
Technical introduction to Hyperledger's Fabric
PDF
Ethereum - Introduction to Smart Contracts
PDF
BigchainDB and Beyond
PDF
BigchainDB - Big Data meets Blockchain
PDF
BigchainDB: A Scalable Blockchain Database, In Python
PDF
Blockchain Use Cases: Think of a "Public" Pub/Sub Queue
PDF
Introduction to Ethereum
PDF
Metadata in the Blockchain: The OP_RETURN Explosion
PDF
Architecture of the Hyperledger Blockchain Fabric - Christian Cachin - IBM Re...
IBM-BLOCKCHAIN-DECK
T-mining presentation at BlockChain Vlaanderen
Smart Contracts and Identity
Ripple Labs: Values, Purpose, Strategy 2014
Open & Private Blockchains at CSCMP Benelux Supply Chain Event
Build Secure IoT Solutions Using... Blockchain - Geeta Chauhan
Conceptualizing Smart Contracts
Smart Gateways, Blockchain and the Internet of Things (Charalampos Doukas-Cre...
Yang Ming Struggling to Keep Up
Secure IoT with Blockchain: Fad or Reality? [BOF5490]
Technical introduction to Hyperledger's Fabric
Ethereum - Introduction to Smart Contracts
BigchainDB and Beyond
BigchainDB - Big Data meets Blockchain
BigchainDB: A Scalable Blockchain Database, In Python
Blockchain Use Cases: Think of a "Public" Pub/Sub Queue
Introduction to Ethereum
Metadata in the Blockchain: The OP_RETURN Explosion
Architecture of the Hyperledger Blockchain Fabric - Christian Cachin - IBM Re...
Ad

Similar to Introduction to Riak and Ripple (KC.rb) (20)

PDF
Riak from Small to Large
PDF
Getting Started with Riak - NoSQL Live 2010 - Boston
KEY
Introducing Riak
KEY
Adding Riak to your NoSQL Bag of Tricks
PDF
Walkthrough Neo4j 1.9 & 2.0
KEY
Riak with Rails
PPTX
Brightstar DB
ZIP
Rails 3 (beta) Roundup
PPTX
StackMate - CloudFormation for CloudStack
PDF
Play Framework and Activator
PDF
Rack
PDF
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
PDF
Ws rest
PDF
PDF
Web Development using Ruby on Rails
KEY
Wider than rails
PDF
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
PPT
Jasig rubyon rails
PPT
Jasig rubyon rails
PDF
Intro to sbt-web
Riak from Small to Large
Getting Started with Riak - NoSQL Live 2010 - Boston
Introducing Riak
Adding Riak to your NoSQL Bag of Tricks
Walkthrough Neo4j 1.9 & 2.0
Riak with Rails
Brightstar DB
Rails 3 (beta) Roundup
StackMate - CloudFormation for CloudStack
Play Framework and Activator
Rack
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ws rest
Web Development using Ruby on Rails
Wider than rails
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Jasig rubyon rails
Jasig rubyon rails
Intro to sbt-web

More from Sean Cribbs (15)

KEY
Eventually Consistent Data Structures (from strangeloop12)
KEY
Eventually-Consistent Data Structures
KEY
A Case of Accidental Concurrency
KEY
Schema Design for Riak (Take 2)
PDF
Riak (Øredev nosql day)
PDF
Riak Tutorial (Øredev)
PDF
The Radiant Ethic
KEY
Schema Design for Riak
PDF
Introducing Riak and Ripple
ZIP
Round PEG, Round Hole - Parsing Functionally
PDF
Story Driven Development With Cucumber
KEY
Achieving Parsing Sanity In Erlang
PDF
Of Rats And Dragons
KEY
Erlang/OTP for Rubyists
PDF
Content Management That Won't Rot Your Brain
Eventually Consistent Data Structures (from strangeloop12)
Eventually-Consistent Data Structures
A Case of Accidental Concurrency
Schema Design for Riak (Take 2)
Riak (Øredev nosql day)
Riak Tutorial (Øredev)
The Radiant Ethic
Schema Design for Riak
Introducing Riak and Ripple
Round PEG, Round Hole - Parsing Functionally
Story Driven Development With Cucumber
Achieving Parsing Sanity In Erlang
Of Rats And Dragons
Erlang/OTP for Rubyists
Content Management That Won't Rot Your Brain

Recently uploaded (20)

PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Electronic commerce courselecture one. Pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Encapsulation theory and applications.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
KodekX | Application Modernization Development
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
MYSQL Presentation for SQL database connectivity
Digital-Transformation-Roadmap-for-Companies.pptx
Spectroscopy.pptx food analysis technology
Dropbox Q2 2025 Financial Results & Investor Presentation
Network Security Unit 5.pdf for BCA BBA.
Electronic commerce courselecture one. Pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Programs and apps: productivity, graphics, security and other tools
Encapsulation theory and applications.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Chapter 3 Spatial Domain Image Processing.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
KodekX | Application Modernization Development
Diabetes mellitus diagnosis method based random forest with bat algorithm
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...

Introduction to Riak and Ripple (KC.rb)

  • 1. Introduction to Riak & Ripple Sean Cribbs basho Developer Advocate
  • 2. Introduction to Riak & Ripple Sean Cribbs basho Developer Advocate Rubyist, Evangelist, Support Monkey
  • 4. Riak @10,000 ft. • Amazon Dynamo-inspired replicated, distributed, fault-tolerant, masterless, scalable, operations-friendly
  • 5. Riak @10,000 ft. • Amazon Dynamo-inspired replicated, distributed, fault-tolerant, masterless, scalable, operations-friendly • Key-Value / Document
  • 6. Riak @10,000 ft. • Amazon Dynamo-inspired replicated, distributed, fault-tolerant, masterless, scalable, operations-friendly • Key-Value / Document • Schema-less, content-agnostic
  • 7. Riak @10,000 ft. • Amazon Dynamo-inspired replicated, distributed, fault-tolerant, masterless, scalable, operations-friendly • Key-Value / Document • Schema-less, content-agnostic • Web-friendly HTTP, JSON, Javascript
  • 9. Dynamo-like Scalability • To get...
  • 10. Dynamo-like Scalability • To get... • more storage,
  • 11. Dynamo-like Scalability • To get... • more storage, • more throughput,
  • 12. Dynamo-like Scalability • To get... • more storage, • more throughput, • lower latency...
  • 13. Dynamo-like Scalability • To get... • more storage, • more throughput, • lower latency... • ...add more machines. aka horizontal & linear
  • 15. Key-Value++ • Data objects are identified by keys, and have metadata
  • 16. Key-Value++ • Data objects are identified by keys, and have metadata • Keys are grouped in buckets
  • 17. Key-Value++ • Data objects are identified by keys, and have metadata • Keys are grouped in buckets • Links enable lightweight relationships
  • 18. Key-Value++ • Data objects are identified by keys, and have metadata • Keys are grouped in buckets • Links enable lightweight relationships • Query with MapReduce
  • 21. Sans-Schema • Buckets created on the fly • Values are opaque
  • 22. Sans-Schema • Buckets created on the fly • Values are opaque •Content-Type matters
  • 23. Sans-Schema • Buckets created on the fly • Values are opaque •Content-Type matters •The application defines the semantics: more flexibility, more responsibility
  • 26. Web-Friendly •HTTP is primary interface •JSON is used for structured data
  • 27. Web-Friendly •HTTP is primary interface •JSON is used for structured data •Javascript is used for MapReduce functions
  • 28. Web-Friendly •HTTP is primary interface •JSON is used for structured data •Javascript is used for MapReduce functions •Plays well with Varnish, Squid, HAProxy, F5, etc.
  • 29. Web-Friendly •HTTP is primary interface •JSON is used for structured data •Javascript is used for MapReduce functions •Plays well with Varnish, Squid, HAProxy, F5, etc. [see also Webmachine]
  • 31. Use Cases •Document storage (sparse structure)
  • 32. Use Cases •Document storage (sparse structure) •Distributed file storage (small size, large soon)
  • 33. Use Cases •Document storage (sparse structure) •Distributed file storage (small size, large soon) •Session storage
  • 34. Use Cases •Document storage (sparse structure) •Distributed file storage (small size, large soon) •Session storage •Distributed cache
  • 35. Use Cases •Document storage (sparse structure) •Distributed file storage (small size, large soon) •Session storage •Distributed cache • Browser-only/Mobile Apps
  • 37. Getting Started • Download a package from http://downloads.basho.com
  • 38. Getting Started • Download a package from http://downloads.basho.com • Set the node name, IPs
  • 39. Getting Started • Download a package from http://downloads.basho.com • Set the node name, IPs • Start up the node
  • 40. Getting Started • Download a package from http://downloads.basho.com • Set the node name, IPs • Start up the node • Join a cluster
  • 41. Getting Started • Download a package from http://downloads.basho.com • Set the node name, IPs • Start up the node • Join a cluster • Start storing/retrieving values
  • 43. Riak in Ruby • Three gems
  • 44. Riak in Ruby • Three gems • riak-client (basic ops)
  • 45. Riak in Ruby • Three gems • riak-client (basic ops) • ripple (ODM)
  • 46. Riak in Ruby • Three gems • riak-client (basic ops) • ripple (ODM) • riak-sessions (Rack/Rails session stores)
  • 47. Riak in Ruby • Three gems • riak-client (basic ops) • ripple (ODM) • riak-sessions (Rack/Rails session stores) • All HTTP - Protobuffs coming
  • 49. require ‘riak’ • Make a client object client = Riak::Client.new
  • 50. require ‘riak’ • Make a client object client = Riak::Client.new • Get a bucket bucket = client.bucket(‘foo’) # Riak::Bucket
  • 51. require ‘riak’ • Make a client object client = Riak::Client.new • Get a bucket bucket = client.bucket(‘foo’) # Riak::Bucket • Get an object from the bucket obj = bucket.get(‘bar’) # Riak::RObject
  • 52. require ‘riak’ • Make a client object client = Riak::Client.new • Get a bucket bucket = client.bucket(‘foo’) # Riak::Bucket • Get an object from the bucket obj = bucket.get(‘bar’) # Riak::RObject • Initialize a new object obj = bucket.new(‘baz’)
  • 54. Riak::RObject •Get/set object key obj.key = “bar”
  • 55. Riak::RObject •Get/set object key obj.key = “bar” •Get/set content-type obj.content_type = ‘application/json’
  • 56. Riak::RObject •Get/set object key obj.key = “bar” •Get/set content-type obj.content_type = ‘application/json’ •Get/set the object body data obj.data = {“name” => “Sean”}
  • 57. Riak::RObject •Get/set object key obj.key = “bar” •Get/set content-type obj.content_type = ‘application/json’ •Get/set the object body data obj.data = {“name” => “Sean”} •Store the object obj.store
  • 59. More RObject •Get object’s bucket obj.bucket
  • 60. More RObject •Get object’s bucket obj.bucket •Delete the object obj.delete # freezes the object
  • 61. More RObject •Get object’s bucket obj.bucket •Delete the object obj.delete # freezes the object •Detect/extract siblings (more later) obj.conflict? && obj.siblings # Array<RObject>
  • 62. More RObject •Get object’s bucket obj.bucket •Delete the object obj.delete # freezes the object •Detect/extract siblings (more later) obj.conflict? && obj.siblings # Array<RObject> •Follow/traverse links (more later) obj.walk(:tag => “friend”)
  • 64. Riak::Bucket •Set the replication factor bucket.n_val = 5
  • 65. Riak::Bucket •Set the replication factor bucket.n_val = 5 •Set default request quorums bucket.r = 3 # w,dw,rw # number or one/all/quorum
  • 66. Riak::Bucket •Set the replication factor bucket.n_val = 5 •Set default request quorums bucket.r = 3 # w,dw,rw # number or one/all/quorum •List keys bucket.keys # pass block to stream
  • 67. Riak::Bucket •Set the replication factor bucket.n_val = 5 •Set default request quorums bucket.r = 3 # w,dw,rw # number or one/all/quorum •List keys bucket.keys # pass block to stream •Set consistency flag (allow sibling generation) obj.allow_mult = true
  • 69. Link Header Link: </riak/demo/test1>; riaktag=”userinfo”
  • 70. Link Header bucket Link: </riak/demo/test1>; riaktag=”userinfo”
  • 71. Link Header bucket Link: </riak/demo/test1>; riaktag=”userinfo” key
  • 72. Link Header bucket tag Link: </riak/demo/test1>; riaktag=”userinfo” key
  • 74. Links in Ruby API • Create a link Riak::Link.new(“/riak/bucket/key”, “tag”)
  • 75. Links in Ruby API • Create a link Riak::Link.new(“/riak/bucket/key”, “tag”) • Read an#object’s links obj.links Set<Riak::Link>
  • 76. Links in Ruby API • Create a link Riak::Link.new(“/riak/bucket/key”, “tag”) • Read an#object’s links obj.links Set<Riak::Link> • Convert<< obj2.to_link(“next”) obj.links an object to a link obj.store
  • 78. Link-Walking • Asks Riak to traverse a sequence of links via special URL
  • 79. Link-Walking • Asks Riak to traverse a sequence of links via special URL • Filter by bucket/tag
  • 80. Link-Walking • Asks Riak to traverse a sequence of links via special URL • Filter by bucket/tag • Can return results from intermediate traversals
  • 81. Link-Walking • Asks Riak to traverse a sequence of links via special URL • Filter by bucket/tag • Can return results from intermediate traversals • Response is nested multipart/mixed (riak-client handles this for you)
  • 83. L/W Example GET /riak/demo/test1/_,friend,1 Start at demo/test1, follow all links tagged “friend” and return the objects obj = client[‘demo’][‘test1’] obj.walk(:tag => “friend”,:keep => true)
  • 84. L/W Example GET /riak/demo/test1/_,friend,1 Start at demo/test1, follow all links tagged “friend” and return the objects obj = client[‘demo’][‘test1’] obj.walk(:tag => “friend”,:keep => true)
  • 86. L/W Example GET /riak/demo/test1/_,_,_/_,_,1 Start at demo/test1, follow all links, follow all links from those, return everything from the last set obj.walk({},{:keep => true})
  • 89. list of keys map map map map map Map-Reduce
  • 90. list of keys map map map map map reduce Map-Reduce
  • 91. list of keys map map map map map reduce results Map-Reduce
  • 92. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
  • 93. Map in Javascript Riak object function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
  • 94. Map in Javascript Riak object function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) { {         if(object[field] != arg[field]) {             return []; bucket:”foo”,         } key:”bar”,     } vclock:”...”,     return [object]; } values:[ {metadata:{...}, data:”....”} ] }
  • 95. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
  • 96. Map in Javascript Key-specific data function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
  • 97. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
  • 98. Map in Javascript Phase- specific data function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
  • 99. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
  • 100. Map in Javascript function(value, keyData, arg) { Parse JSON data     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
  • 101. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
  • 102. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     } Check field equality     return [object]; }
  • 103. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
  • 104. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return []; Return nothing if unequal         }     }     return [object]; }
  • 105. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
  • 106. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; Return the object if all equal }
  • 107. Map in Javascript function(value, keyData, arg) {     var object = Riak.mapValuesJson(value)[0];     for(field in arg) {         if(object[field] != arg[field]) {             return [];         }     }     return [object]; }
  • 108. Reduce in Javascript function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); }
  • 109. Reduce in Javascript Map results function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); }
  • 110. Reduce in Javascript function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); }
  • 111. Reduce in Javascript Phase- specific data function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); }
  • 112. Reduce in Javascript function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); }
  • 113. Reduce in Javascript function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); Custom sort on }
  • 114. Reduce in Javascript function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); }
  • 115. Reduce in Javascript function(values,arg) {     return values.sort(function(a,b){ return a[arg] - b[arg]; }); } Reduce potentially called multiple times!!
  • 117. Example Query {“inputs”: “goog”, “query”: [{“map”:{“language”:”javascript”, “name”: “App.findHighGreater”, “arg”: 600.0, “keep”: false}, {“reduce”:{“language”:”javascript”, “name”: “Riak.reduceMax”, “keep”: true}]}
  • 118. Example Query {“inputs”: “goog”, “query”: [{“map”:{“language”:”javascript”, “name”: “App.findHighGreater”, “arg”: 600.0, “keep”: false}, {“reduce”:{“language”:”javascript”, “name”: “Riak.reduceMax”, “keep”: true}]} Riak::MapReduce.new(c).add(‘goog’). map(‘App.findHighGreater’, :arg => 600.0). reduce(“Riak.reduceMax”, :keep => true).run
  • 122. Built-in Functions • Riak.mapValues • Riak.mapValuesJson • Riak.mapByFields
  • 123. Built-in Functions • Riak.mapValues • Riak.mapValuesJson • Riak.mapByFields • Riak.reduceSum
  • 124. Built-in Functions • Riak.mapValues • Riak.mapValuesJson • Riak.mapByFields • Riak.reduceSum • Riak.reduceSort
  • 125. Built-in Functions • Riak.mapValues • Riak.mapValuesJson • Riak.mapByFields • Riak.reduceSum • Riak.reduceSort • Riak.reduceMin/reduceMax
  • 127. Document Models class Person include Ripple::Document property :name, String, :presence => true many :addresses many :friends, :class => Person end class Address include Ripple::EmbeddedDocument property :street, String end
  • 129. Rails Setup # Gemfile gem 'curb' # Faster HTTP gem 'yajl-ruby' # Faster JSON gem 'ripple'
  • 130. Rails Setup # Gemfile gem 'curb' # Faster HTTP gem 'yajl-ruby' # Faster JSON gem 'ripple'
  • 131. Rails Setup # Gemfile gem 'curb' # Faster HTTP gem 'yajl-ruby' # Faster JSON gem 'ripple' $ gem install curb yajl-ruby ripple
  • 133. Rails Setup (cont.) # config/ripple.yml development: host: 127.0.0.1 port: 8098
  • 134. Rails Setup (cont.) # config/ripple.yml development: host: 127.0.0.1 port: 8098 # config/application.rb require 'ripple/railtie'
  • 136. Ripple Roadmap • Testing server (edge on Github)
  • 137. Ripple Roadmap • Testing server (edge on Github) • Protocol Buffers support
  • 138. Ripple Roadmap • Testing server (edge on Github) • Protocol Buffers support • Streaming MapReduce
  • 139. Ripple Roadmap • Testing server (edge on Github) • Protocol Buffers support • Streaming MapReduce • Ripple-specific built-ins
  • 140. Ripple Roadmap • Testing server (edge on Github) • Protocol Buffers support • Streaming MapReduce • Ripple-specific built-ins • Better ActionView support (form_for)
  • 143. Plug Interested in learning about support, consulting, or Enterprise features? basho
  • 144. Plug Interested in learning about support, consulting, or Enterprise features? Email info@basho.com or go to http://www.basho.com/ contact.html to talk with us. basho
  • 145. Plug Interested in learning about support, consulting, or Enterprise features? Email info@basho.com or go to http://www.basho.com/ contact.html to talk with us. basho
  • 146. Plug Interested in learning about support, consulting, or Enterprise features? Email info@basho.com or go to http://www.basho.com/ contact.html to talk with us. www.basho.com sean@basho.com @seancribbs basho