SlideShare a Scribd company logo
1 of 33
Riak with Rails
   Sean Cribbs
   Developer Advocate




basho
Why Riak with Rails?

        Simple to understand and use
        Share-nothing, homogeneous
        Web-friendly
        Grows with your app (“scales”)
        Lots of use-cases



basho
Use Cases

        Document database
        File / upload storage (DFS)
        Cache / object store
        Session store




basho
Getting Started

   # Gemfile
   gem 'curb'    # Faster HTTP
   gem 'yajl-ruby' # Faster JSON
   gem 'riak-client', :require => 'riak'
   gem 'ripple'


   $ gem install curb yajl-ruby ripple


basho
Rails 3 Setup

   # config/ripple.yml
   development:
    host: 127.0.0.1
    port: 8098


   # config/application.rb
   require 'ripple/railtie'



basho
Basic Client Operations



basho
require ‘riak’
        Make a client object
        client = Riak::Client.new # or Ripple.client

        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’)


basho
Riak::RObject
        Get/set object key
        obj.key = “bar”

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

        Get/set the object body data (JSON auto enc/dec)
        obj.data = {“name” => “Sean”}

        Store the object
        obj.store


basho
Using Links

        Create a link
        Riak::Link.new(“/riak/bucket/key”, “tag”)

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

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



basho
Link-Walking
   obj = client[‘demo’][‘test1’]
   obj.walk(:keep => true)
     # Get all linked one-level

   obj.walk(:bucket => “demo”, :keep => true)
     # Get all linked in “demo” bucket

   obj.walk(:tag => ‘friend’, :keep => true)
     # Get all linked with tag “friend”

   obj.walk({},{:keep => true})
     # Get all linked at second level


basho
MapReduce

   mr = Riak::MapReduce.new(Ripple.client)
   mr.add(“people”,”sean”)
   mr.link(:tag => “friend”)
   mr.map(“Riak.mapValuesJson”,:keep => true)
   mr.run

   Riak::MapReduce.new(Ripple.client).
    add(“people”,”sean”).
    link(:tag => “friend”).
    map(“Riak.mapValuesJson”,:keep => true).run



basho
Load RObjects from M/R


        Javascript Identity Map Function
        function(v){ return [v]; }

        Load output
        Riak::RObject.load_from_mapreduce(c, mr.run)
         # Returns Array<Riak::RObject>




basho
Use-Case: Document DB



basho
Riak as Document DB

        Store semi-structured data as “documents” (JSON)
        Alternative to CouchDB or MongoDB
        Links and Link-walking for easy relationships
        MapReduce for more involved queries




basho
Ripple - Document OM

        Build rich, multi-level nested document models
        ActiveModel goodies: validations, callbacks, etc
        Associations -- embedded, linked
        Requires Rails 3.0.0.rc




basho
Caveats


        No indexes for efficient lookups (other than key)
        Still pretty new
        Currently hard to clean up after tests




basho
Ripple Demo



basho
Use Case: File storage



basho
Riak as a File Server


        Web-shaped storage - plays well with ops
        Authenticated downloads
        Serve files directly from Riak




basho
File Upload / Serve Demo



basho
Use-Case: Cache store



basho
Riak as a Cache Store
        It’s a K/V store - similar to memcached, redis
        Flexible serialization options: JSON, YAML, Marshal,
        text, binary
        Tune for performance over consistency
          Low quorums and replication
          Last-write-wins?
          In-memory backend


basho
Using Riak::CacheStore

        Implements ActiveSupport::Cache::Store
        Sets quorum/n_val defaults for you (tweakable)
          R=W=RW=1, DW=0, N=2
        Doesn’t set backend or last_write_wins (tweakable)
        config.cache_store = :riak_store



basho
Caveats


        Not as fast as memcached or redis
        No per-object expiry (could be done client-side)




basho
Riak::CacheStore Demo



basho
Use-Case: Session store



basho
Riak as a Session store

        Substitute for ActiveRecord or memcached sessions
        Use when you need larger or longer-lived sessions
        Tune for modest durability and performance
          Low quorums, modest N (2 or 3)
          Fast disk backend (bitcask) or memory (ets)



basho
Ripple::SessionStore (WIP)

        Sets quorum/n_val defaults for you
        Implements ActionDispatch::Session::AbstractStore
        config.session_store = ::Riak::SessionStore
        Coming in next release of Ripple (0.8.0)




basho
Wrap-up



basho
Riak with Rails
        Useful in many contexts
          Semi-structured data/documents
          Web-friendly storage
          Distributed cache / session storage
          Flexible K/V storage
        Grows with your app


basho
Ripple Roadmap

        Testing assistance/automation
        Protocol buffers interface, HTTP enhancements
        More association types
        Get involved: http://github.com/seancribbs/ripple




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




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

More Related Content

What's hot

Getting Started with Capistrano
Getting Started with CapistranoGetting Started with Capistrano
Getting Started with CapistranoLaunchAny
 
Going crazy with Varnish and Symfony
Going crazy with Varnish and SymfonyGoing crazy with Varnish and Symfony
Going crazy with Varnish and SymfonyDavid de Boer
 
Provisioning iOS CI Server with Ansible
Provisioning iOS CI Server with AnsibleProvisioning iOS CI Server with Ansible
Provisioning iOS CI Server with AnsibleShashikant Jagtap
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsRemy Sharp
 
Manage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliManage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliGetSource
 
Chef, Vagrant, and VirtualBox
Chef, Vagrant, and VirtualBoxChef, Vagrant, and VirtualBox
Chef, Vagrant, and VirtualBoxJason Vanderhoof
 
Ansible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / QuickstartAnsible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / QuickstartHenry Stamerjohann
 
PyCon Russia 2014 - Auto Scale in the Cloud
PyCon Russia 2014 - Auto Scale in the CloudPyCon Russia 2014 - Auto Scale in the Cloud
PyCon Russia 2014 - Auto Scale in the CloudSimone Soldateschi
 
Plack basics for Perl websites - YAPC::EU 2011
Plack basics for Perl websites - YAPC::EU 2011Plack basics for Perl websites - YAPC::EU 2011
Plack basics for Perl websites - YAPC::EU 2011leo lapworth
 
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliWordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliGetSource
 
How to deploy your Rails application on Windows
How to deploy your Rails application on WindowsHow to deploy your Rails application on Windows
How to deploy your Rails application on Windows曦 徐
 
Usecase examples of Packer
Usecase examples of Packer Usecase examples of Packer
Usecase examples of Packer Hiroshi SHIBATA
 
We broke up with the monolith, and started dating #eventSourcing - #symfonyCat
We broke up with the monolith, and started dating #eventSourcing - #symfonyCatWe broke up with the monolith, and started dating #eventSourcing - #symfonyCat
We broke up with the monolith, and started dating #eventSourcing - #symfonyCatJavier Ferrer González
 
Asynchronous Threads in Lasso 8.5
Asynchronous Threads in Lasso 8.5Asynchronous Threads in Lasso 8.5
Asynchronous Threads in Lasso 8.5bilcorry
 
V2 and beyond
V2 and beyondV2 and beyond
V2 and beyondjimi-c
 
[drupalday2017] - Drupal come frontend che consuma servizi: HTTP Client Manager
[drupalday2017] - Drupal come frontend che consuma servizi: HTTP Client Manager[drupalday2017] - Drupal come frontend che consuma servizi: HTTP Client Manager
[drupalday2017] - Drupal come frontend che consuma servizi: HTTP Client ManagerDrupalDay
 

What's hot (20)

Getting Started with Capistrano
Getting Started with CapistranoGetting Started with Capistrano
Getting Started with Capistrano
 
Going crazy with Varnish and Symfony
Going crazy with Varnish and SymfonyGoing crazy with Varnish and Symfony
Going crazy with Varnish and Symfony
 
Provisioning iOS CI Server with Ansible
Provisioning iOS CI Server with AnsibleProvisioning iOS CI Server with Ansible
Provisioning iOS CI Server with Ansible
 
Capistrano
CapistranoCapistrano
Capistrano
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
 
Manage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliManage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cli
 
Chef, Vagrant, and VirtualBox
Chef, Vagrant, and VirtualBoxChef, Vagrant, and VirtualBox
Chef, Vagrant, and VirtualBox
 
Ansible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / QuickstartAnsible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / Quickstart
 
PyCon Russia 2014 - Auto Scale in the Cloud
PyCon Russia 2014 - Auto Scale in the CloudPyCon Russia 2014 - Auto Scale in the Cloud
PyCon Russia 2014 - Auto Scale in the Cloud
 
Plack basics for Perl websites - YAPC::EU 2011
Plack basics for Perl websites - YAPC::EU 2011Plack basics for Perl websites - YAPC::EU 2011
Plack basics for Perl websites - YAPC::EU 2011
 
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliWordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
 
How to deploy your Rails application on Windows
How to deploy your Rails application on WindowsHow to deploy your Rails application on Windows
How to deploy your Rails application on Windows
 
Puppet
PuppetPuppet
Puppet
 
Usecase examples of Packer
Usecase examples of Packer Usecase examples of Packer
Usecase examples of Packer
 
201904 websocket
201904 websocket201904 websocket
201904 websocket
 
We broke up with the monolith, and started dating #eventSourcing - #symfonyCat
We broke up with the monolith, and started dating #eventSourcing - #symfonyCatWe broke up with the monolith, and started dating #eventSourcing - #symfonyCat
We broke up with the monolith, and started dating #eventSourcing - #symfonyCat
 
Asynchronous Threads in Lasso 8.5
Asynchronous Threads in Lasso 8.5Asynchronous Threads in Lasso 8.5
Asynchronous Threads in Lasso 8.5
 
V2 and beyond
V2 and beyondV2 and beyond
V2 and beyond
 
Rails caching
Rails cachingRails caching
Rails caching
 
[drupalday2017] - Drupal come frontend che consuma servizi: HTTP Client Manager
[drupalday2017] - Drupal come frontend che consuma servizi: HTTP Client Manager[drupalday2017] - Drupal come frontend che consuma servizi: HTTP Client Manager
[drupalday2017] - Drupal come frontend che consuma servizi: HTTP Client Manager
 

Similar to Riak with Rails

Riak from Small to Large
Riak from Small to LargeRiak from Small to Large
Riak from Small to LargeRusty Klophaus
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developergicappa
 
Riak with node.js
Riak with node.jsRiak with node.js
Riak with node.jsSean Cribbs
 
Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)Sean Cribbs
 
Riak at The NYC Cloud Computing Meetup Group
Riak at The NYC Cloud Computing Meetup GroupRiak at The NYC Cloud Computing Meetup Group
Riak at The NYC Cloud Computing Meetup Groupsiculars
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaYevgeniy Brikman
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareAlona Mekhovova
 
Backbone the Good Parts
Backbone the Good PartsBackbone the Good Parts
Backbone the Good PartsRenan Carvalho
 
(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...
(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...
(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...Amazon Web Services
 
Riak Intro at Munich Node.js
Riak Intro at Munich Node.jsRiak Intro at Munich Node.js
Riak Intro at Munich Node.jsPhilipp Fehre
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Racksickill
 
Serverless Ballerina
Serverless BallerinaServerless Ballerina
Serverless BallerinaBallerina
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaJason Noble
 
PUT Knowledge BUCKET Brain KEY Riak
PUT Knowledge BUCKET Brain KEY RiakPUT Knowledge BUCKET Brain KEY Riak
PUT Knowledge BUCKET Brain KEY RiakPhilipp Fehre
 
Heat up your stack
Heat up your stackHeat up your stack
Heat up your stackRico Lin
 
Embrace NoSQL and Eventual Consistency with Ripple
Embrace NoSQL and Eventual Consistency with RippleEmbrace NoSQL and Eventual Consistency with Ripple
Embrace NoSQL and Eventual Consistency with RippleSean Cribbs
 
HTML5: huh, what is it good for?
HTML5: huh, what is it good for?HTML5: huh, what is it good for?
HTML5: huh, what is it good for?Remy Sharp
 
Hammock, a Good Place to Rest
Hammock, a Good Place to RestHammock, a Good Place to Rest
Hammock, a Good Place to RestStratoscale
 

Similar to Riak with Rails (20)

Riak from Small to Large
Riak from Small to LargeRiak from Small to Large
Riak from Small to Large
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
Riak with node.js
Riak with node.jsRiak with node.js
Riak with node.js
 
Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)
 
Riak at The NYC Cloud Computing Meetup Group
Riak at The NYC Cloud Computing Meetup GroupRiak at The NYC Cloud Computing Meetup Group
Riak at The NYC Cloud Computing Meetup Group
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
Backbone the Good Parts
Backbone the Good PartsBackbone the Good Parts
Backbone the Good Parts
 
(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...
(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...
(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...
 
Riak Intro at Munich Node.js
Riak Intro at Munich Node.jsRiak Intro at Munich Node.js
Riak Intro at Munich Node.js
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
Serverless Ballerina
Serverless BallerinaServerless Ballerina
Serverless Ballerina
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp Atlanta
 
PUT Knowledge BUCKET Brain KEY Riak
PUT Knowledge BUCKET Brain KEY RiakPUT Knowledge BUCKET Brain KEY Riak
PUT Knowledge BUCKET Brain KEY Riak
 
RoR guide_p1
RoR guide_p1RoR guide_p1
RoR guide_p1
 
Heat up your stack
Heat up your stackHeat up your stack
Heat up your stack
 
Embrace NoSQL and Eventual Consistency with Ripple
Embrace NoSQL and Eventual Consistency with RippleEmbrace NoSQL and Eventual Consistency with Ripple
Embrace NoSQL and Eventual Consistency with Ripple
 
HTML5: huh, what is it good for?
HTML5: huh, what is it good for?HTML5: huh, what is it good for?
HTML5: huh, what is it good for?
 
Hammock, a Good Place to Rest
Hammock, a Good Place to RestHammock, a Good Place to Rest
Hammock, a Good Place to Rest
 
Rack
RackRack
Rack
 

More from Sean Cribbs

Eventually Consistent Data Structures (from strangeloop12)
Eventually Consistent Data Structures (from strangeloop12)Eventually Consistent Data Structures (from strangeloop12)
Eventually Consistent Data Structures (from strangeloop12)Sean Cribbs
 
Eventually-Consistent Data Structures
Eventually-Consistent Data StructuresEventually-Consistent Data Structures
Eventually-Consistent Data StructuresSean Cribbs
 
A Case of Accidental Concurrency
A Case of Accidental ConcurrencyA Case of Accidental Concurrency
A Case of Accidental ConcurrencySean Cribbs
 
Schema Design for Riak (Take 2)
Schema Design for Riak (Take 2)Schema Design for Riak (Take 2)
Schema Design for Riak (Take 2)Sean Cribbs
 
Riak (Øredev nosql day)
Riak (Øredev nosql day)Riak (Øredev nosql day)
Riak (Øredev nosql day)Sean Cribbs
 
Riak Tutorial (Øredev)
Riak Tutorial (Øredev)Riak Tutorial (Øredev)
Riak Tutorial (Øredev)Sean Cribbs
 
The Radiant Ethic
The Radiant EthicThe Radiant Ethic
The Radiant EthicSean Cribbs
 
Schema Design for Riak
Schema Design for RiakSchema Design for Riak
Schema Design for RiakSean Cribbs
 
Introduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf TrainingIntroduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf TrainingSean Cribbs
 
Introducing Riak and Ripple
Introducing Riak and RippleIntroducing Riak and Ripple
Introducing Riak and RippleSean Cribbs
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallyRound PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallySean Cribbs
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With CucumberSean Cribbs
 
Achieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangAchieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangSean Cribbs
 
Of Rats And Dragons
Of Rats And DragonsOf Rats And Dragons
Of Rats And DragonsSean Cribbs
 
Erlang/OTP for Rubyists
Erlang/OTP for RubyistsErlang/OTP for Rubyists
Erlang/OTP for RubyistsSean Cribbs
 
Content Management That Won't Rot Your Brain
Content Management That Won't Rot Your BrainContent Management That Won't Rot Your Brain
Content Management That Won't Rot Your BrainSean Cribbs
 

More from Sean Cribbs (16)

Eventually Consistent Data Structures (from strangeloop12)
Eventually Consistent Data Structures (from strangeloop12)Eventually Consistent Data Structures (from strangeloop12)
Eventually Consistent Data Structures (from strangeloop12)
 
Eventually-Consistent Data Structures
Eventually-Consistent Data StructuresEventually-Consistent Data Structures
Eventually-Consistent Data Structures
 
A Case of Accidental Concurrency
A Case of Accidental ConcurrencyA Case of Accidental Concurrency
A Case of Accidental Concurrency
 
Schema Design for Riak (Take 2)
Schema Design for Riak (Take 2)Schema Design for Riak (Take 2)
Schema Design for Riak (Take 2)
 
Riak (Øredev nosql day)
Riak (Øredev nosql day)Riak (Øredev nosql day)
Riak (Øredev nosql day)
 
Riak Tutorial (Øredev)
Riak Tutorial (Øredev)Riak Tutorial (Øredev)
Riak Tutorial (Øredev)
 
The Radiant Ethic
The Radiant EthicThe Radiant Ethic
The Radiant Ethic
 
Schema Design for Riak
Schema Design for RiakSchema Design for Riak
Schema Design for Riak
 
Introduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf TrainingIntroduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf Training
 
Introducing Riak and Ripple
Introducing Riak and RippleIntroducing Riak and Ripple
Introducing Riak and Ripple
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallyRound PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing Functionally
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
 
Achieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangAchieving Parsing Sanity In Erlang
Achieving Parsing Sanity In Erlang
 
Of Rats And Dragons
Of Rats And DragonsOf Rats And Dragons
Of Rats And Dragons
 
Erlang/OTP for Rubyists
Erlang/OTP for RubyistsErlang/OTP for Rubyists
Erlang/OTP for Rubyists
 
Content Management That Won't Rot Your Brain
Content Management That Won't Rot Your BrainContent Management That Won't Rot Your Brain
Content Management That Won't Rot Your Brain
 

Recently uploaded

A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Recently uploaded (20)

A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

Riak with Rails

  • 1. Riak with Rails Sean Cribbs Developer Advocate basho
  • 2. Why Riak with Rails? Simple to understand and use Share-nothing, homogeneous Web-friendly Grows with your app (“scales”) Lots of use-cases basho
  • 3. Use Cases Document database File / upload storage (DFS) Cache / object store Session store basho
  • 4. Getting Started # Gemfile gem 'curb' # Faster HTTP gem 'yajl-ruby' # Faster JSON gem 'riak-client', :require => 'riak' gem 'ripple' $ gem install curb yajl-ruby ripple basho
  • 5. Rails 3 Setup # config/ripple.yml development: host: 127.0.0.1 port: 8098 # config/application.rb require 'ripple/railtie' basho
  • 7. require ‘riak’ Make a client object client = Riak::Client.new # or Ripple.client 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’) basho
  • 8. Riak::RObject Get/set object key obj.key = “bar” Get/set content-type obj.content_type = ‘application/json’ Get/set the object body data (JSON auto enc/dec) obj.data = {“name” => “Sean”} Store the object obj.store basho
  • 9. Using Links Create a link Riak::Link.new(“/riak/bucket/key”, “tag”) Read an object’s links obj.links # Set<Riak::Link> Convert an object to a link obj.links << obj2.to_link(“next”) obj.store basho
  • 10. Link-Walking obj = client[‘demo’][‘test1’] obj.walk(:keep => true) # Get all linked one-level obj.walk(:bucket => “demo”, :keep => true) # Get all linked in “demo” bucket obj.walk(:tag => ‘friend’, :keep => true) # Get all linked with tag “friend” obj.walk({},{:keep => true}) # Get all linked at second level basho
  • 11. MapReduce mr = Riak::MapReduce.new(Ripple.client) mr.add(“people”,”sean”) mr.link(:tag => “friend”) mr.map(“Riak.mapValuesJson”,:keep => true) mr.run Riak::MapReduce.new(Ripple.client). add(“people”,”sean”). link(:tag => “friend”). map(“Riak.mapValuesJson”,:keep => true).run basho
  • 12. Load RObjects from M/R Javascript Identity Map Function function(v){ return [v]; } Load output Riak::RObject.load_from_mapreduce(c, mr.run) # Returns Array<Riak::RObject> basho
  • 14. Riak as Document DB Store semi-structured data as “documents” (JSON) Alternative to CouchDB or MongoDB Links and Link-walking for easy relationships MapReduce for more involved queries basho
  • 15. Ripple - Document OM Build rich, multi-level nested document models ActiveModel goodies: validations, callbacks, etc Associations -- embedded, linked Requires Rails 3.0.0.rc basho
  • 16. Caveats No indexes for efficient lookups (other than key) Still pretty new Currently hard to clean up after tests basho
  • 18. Use Case: File storage basho
  • 19. Riak as a File Server Web-shaped storage - plays well with ops Authenticated downloads Serve files directly from Riak basho
  • 20. File Upload / Serve Demo basho
  • 22. Riak as a Cache Store It’s a K/V store - similar to memcached, redis Flexible serialization options: JSON, YAML, Marshal, text, binary Tune for performance over consistency Low quorums and replication Last-write-wins? In-memory backend basho
  • 23. Using Riak::CacheStore Implements ActiveSupport::Cache::Store Sets quorum/n_val defaults for you (tweakable) R=W=RW=1, DW=0, N=2 Doesn’t set backend or last_write_wins (tweakable) config.cache_store = :riak_store basho
  • 24. Caveats Not as fast as memcached or redis No per-object expiry (could be done client-side) basho
  • 27. Riak as a Session store Substitute for ActiveRecord or memcached sessions Use when you need larger or longer-lived sessions Tune for modest durability and performance Low quorums, modest N (2 or 3) Fast disk backend (bitcask) or memory (ets) basho
  • 28. Ripple::SessionStore (WIP) Sets quorum/n_val defaults for you Implements ActionDispatch::Session::AbstractStore config.session_store = ::Riak::SessionStore Coming in next release of Ripple (0.8.0) basho
  • 30. Riak with Rails Useful in many contexts Semi-structured data/documents Web-friendly storage Distributed cache / session storage Flexible K/V storage Grows with your app basho
  • 31. Ripple Roadmap Testing assistance/automation Protocol buffers interface, HTTP enhancements More association types Get involved: http://github.com/seancribbs/ripple basho
  • 32. 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 basho
  • 33. 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

Editor's Notes