SlideShare une entreprise Scribd logo
1  sur  33
Adding Riak to your
NoSQL Bag of Tricks
         NoSQL-NYC, October 2010

                  Alexander Sicular
                         @siculars
Riak, eh?
•   Dynamo inspired

•   Homogeneous

•   Single key-space

•   Distributed

•   Replicated

•   Predictable scaleability

•   Data agnostic
Origins
    Show me your friends...


•    Amazon’s Dynamo
     http://www.allthingsdistributed.com/2007/10/
     amazons_dynamo.html



•    Akamai
     http://www.basho.com/bios.html




                                                    Paramount Home Video
CAP Theorem
                         http://en.wikipedia.org/wiki/CAP_theorem




    •   Consistency

    •   Availability

    •   Partition tolerance


         Pick two?
Riak says: pick two at a time.
                                                                    http://guide.couchdb.org/draft/consistency.html
Homogeneous

•   Every node is the same

•   Any node can service
    any request

•   Nodes gossip on their
    own port
One Ring to Rule Them All
Single 160 bit key space

Huh?

No Sharding!
Distributed (!= replicated)
•   riak is not sharded
                             ★Considerations:
•   vnodes = units of          -must plan maximum ring
    distribution               size
•   vnodes != physical         -think about number of
    nodes (pnodes)             vnodes per pnode
•   vnodes map to pnodes       -generally no less than 10
•   data is distributed at     vnodes per pnode
    the vnode level
Conflict Resolution

• Vector Clocks
• ancestry / divergency maintained
• automatic or manual resolution
★Considerations:
  • X-Riak-ClientId,
  • X-Riak-Vclock
  • allow_mult
Replicated (!= distributed)
• configurable replication values (“N”)
• configurable consistency and availability
  values at read and write time
  -   read

  -   write
  -   durable write
Predictable Scaleability
• How much performance per node?
• Scale in both directions
>bin/riak-admin
>Usage: riak-admin { join   |
  leave | backup | restore |
  test | status | reip |
  js_reload | wait-for-service
  | ringready | transfers }
Data Agnostic
   • schemaless
   • data objects may be of any type
   • binary, text (json, xml)
   • use content types
>curl -v -d 'this is a test' -H "Content-Type: text/plain" 
http://127.0.0.1:8098/riak/testBucket/testKey
Extra Goodies
•   Erlang
    http://www.pragprog.com/titles/jaerlang/
    programming-erlang



•   Code Architecture

•   basho_bench

•   Multiple backends

      •     bitcask

      •     innodb
Code architecture
• Highly modularized
 • riak_core
 • riak_kv
 • bitcask
 • erlang_js
                       http://bitbucket.org/basho
basho_bench
• Performance profiling
• highly customizable
• pretty pictures
• key/value store generalized
  https://wiki.basho.com/display/RIAK/Benchmarking+with+Basho+Bench

  http://pics.livejournal.com/demmonoid/pic/00001sa7
Bitcask
• Riak’s default disk backend
• Write Only Log
• Heavy updates will grow your footprint
   - Look into compaction/merging settings
• Keys are cached in memory with disk offsets
  https://spreadsheets.google.com/ccc?
  key=0Ak4OBkABJPsxdEowYXc2akxnYU9xNkJmbmZscnhaTFE&hl=en&authkey=CMHw8tYO
Speak my language?
•   HTTP
http://wiki.basho.com/display/RIAK/REST+API



•   Protocol Buffers
http://wiki.basho.com/display/RIAK/PBC+API



•   Native Erlang
http://wiki.basho.com/display/RIAK/Erlang+Client
+PBC


                                                                http://www.zazzle.com/
                                                   speak_to_me_in_tagalog_tshirt-235376204895796392
Ok sounds good.
   How do I get it?
>hg clone http://
bitbucket.org/basho/riak
>cd riak
>make all && make rel
       OR if you’re on a mac:
>brew install riak
What does that get
        me?
• Fully functional
• Self contained (<3)
• Default configuration
 -64 vnodes, “riak” cookie, N = 3
Work... like so.

•   Config files
    http://wiki.basho.com/display/RIAK/Configuration+Files




•   app.config
    -ring_creation_size


•   vm.args
    -name, -settings
Fire it up

> bin/riak
> Usage: riak {start|stop|restart|reboot|
  ping|console|attach}

> bin/riak   start
Do Stuff!
    GET:

>   curl -v http://127.0.0.1:8098/ping

>   curl -v http://127.0.0.1:8098/stats

>   curl -v http://127.0.0.1:8098/riak/myBucket

>   curl -v http://127.0.0.1:8098/riak/myBucket/myKey

    PUT:

>   curl -v -X PUT -H "Content-Type: application/json" -d
    '{"backend": "ets"}' http://127.0.0.1:8098/riak/myBucket

>   curl -v -X PUT -d 'test key' http://127.0.0.1:8098/riak/
    myBucket/myKey

>   curl -v -X POST -d 'autogen key' http://127.0.0.1:8098/
    riak/myBucket
Links
•   Lightweight Graphing
•   Practical limitations re. number of links per
    object
•   Unidirectional object linking
•   relationship modeling (one to one, one to many)
•   Returns “Content-Type: multipart/mixed;”
     -   Library needs to be multipart aware
     -   nodejs, formidable
Link Walking
First level depth
>curl http://localhost:8098/riak/myBucket/myKey/_,_,_

Via Map/Reduce
>$ curl -X POST -H "content-type:application/json" 
   http://localhost:8098/mapred --data @-
{"inputs":[["myBucket","myKey"]],"query":[{"link":{}},{"map":
{"language":"javascript","source":"function(v)
{ return [v]; }"}}]}
^D

N level depth
>curl http://localhost:8098/riak/myBucket/myKey/_,_,_/_,_,_


More Info:
http://blog.basho.com/2010/02/24/link-walking-by-example/
http://wiki.basho.com/display/RIAK/Links
http://wiki.basho.com/display/RIAK/REST+API#RESTAPI-Linkwalking
Map/Reduce
• Functions written in either Erlang or
  JavaScript
• Map is distributed to where the data lives
• Reduce is run on the node coordinating the
  M/R
• Erlang > JavaScript
• Tweak JavaScript settings in app.conf
M/R in Riak
•   An input to start from
                                  function(v, keydata, args) {
    • bucket                      
                                  
                                           if (v.values) {
                                             var ret = [], o = {};

    • list of keys                
                                  
                                             o = Riak.mapValuesJson(v)[0]; 
                                             o.lastModifiedParsed = Date.parse(v["values"][0]["metadata"] 
                                  ["X-Riak-Last-Modified"]);
    ★ keys > bucket               
                                  
                                             o.key = v["key"];
                                             ret.push(o);

•   possible link phase           
                                  
                                             return ret;
                                           } else {
                                  
          return [];
•   one or more map phases        
                                  
      };
                                           }


•   (many) possible reduce phase(s)


 Map = SQL Where clause
Reduce = SQL Aggregates (SUM, COUNT, GROUP BY)
Pre/Post Commit
              Hooks
•   Pre Commit                 •   Post Commit

    •   JavaScript or Erlang       •   Erlang

    •   Validation                 •   Indexing

    •   Modify data                •   Messaging

    •   Kill writes
Code demo
• nodejs
• riak-js
• redis
• simple post site
• tags
• json data passing
Chief complaints

   •    No index

   •    No native sort

   •    No increment

   •    No full text search *



                          *Yet ;) inc Riak Search!
http://www.slideshare.net/rklophaus/riak-search-erlang-factory-london-2010
Hybrid architectures
  are the future!
Use tools like Redis to augment shortcomings!
1,456,023 Or “A Lot”

•   At scale, precision does
    not matter in practice.

    •   Google

    •   Twitter



                               http://photography.nationalgeographic.com/photography/enlarge/
                                           okavango-cape-buffalo_pod_image.html
Google
         Look Ma!

         No exact counts!
Twitter


No Totals!



                       No Pagination!
Questions?




         Alexander Sicular
                @siculars

Contenu connexe

Tendances

Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nl
bartzon
 

Tendances (20)

Cassandra and materialized views
Cassandra and materialized viewsCassandra and materialized views
Cassandra and materialized views
 
Hadoop on osx
Hadoop on osxHadoop on osx
Hadoop on osx
 
Scaling php applications with redis
Scaling php applications with redisScaling php applications with redis
Scaling php applications with redis
 
The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015
 
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
 
Apache Sqoop: Unlocking Hadoop for Your Relational Database
Apache Sqoop: Unlocking Hadoop for Your Relational Database Apache Sqoop: Unlocking Hadoop for Your Relational Database
Apache Sqoop: Unlocking Hadoop for Your Relational Database
 
Data Analytics Service Company and Its Ruby Usage
Data Analytics Service Company and Its Ruby UsageData Analytics Service Company and Its Ruby Usage
Data Analytics Service Company and Its Ruby Usage
 
Data stax academy
Data stax academyData stax academy
Data stax academy
 
Introduction to cloudforecast
Introduction to cloudforecastIntroduction to cloudforecast
Introduction to cloudforecast
 
Gemification plan of Standard Library on Ruby
Gemification plan of Standard Library on RubyGemification plan of Standard Library on Ruby
Gemification plan of Standard Library on Ruby
 
Developing and Deploying Apps with the Postgres FDW
Developing and Deploying Apps with the Postgres FDWDeveloping and Deploying Apps with the Postgres FDW
Developing and Deploying Apps with the Postgres FDW
 
Riak add presentation
Riak add presentationRiak add presentation
Riak add presentation
 
11. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/211. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/2
 
Lightning fast analytics with Spark and Cassandra
Lightning fast analytics with Spark and CassandraLightning fast analytics with Spark and Cassandra
Lightning fast analytics with Spark and Cassandra
 
User defined-functions-cassandra-summit-eu-2014
User defined-functions-cassandra-summit-eu-2014User defined-functions-cassandra-summit-eu-2014
User defined-functions-cassandra-summit-eu-2014
 
Speed up your Symfony2 application and build awesome features with Redis
Speed up your Symfony2 application and build awesome features with RedisSpeed up your Symfony2 application and build awesome features with Redis
Speed up your Symfony2 application and build awesome features with Redis
 
MongoDB开发应用实践
MongoDB开发应用实践MongoDB开发应用实践
MongoDB开发应用实践
 
Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application
 
Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nl
 
OSMC 2013 | Log- und Eventmanagement by Bernd Erk
OSMC 2013 |  Log- und Eventmanagement by Bernd ErkOSMC 2013 |  Log- und Eventmanagement by Bernd Erk
OSMC 2013 | Log- und Eventmanagement by Bernd Erk
 

En vedette

En vedette (6)

Accessibility more than just alt tags
Accessibility more than just alt tagsAccessibility more than just alt tags
Accessibility more than just alt tags
 
How to Present
How to PresentHow to Present
How to Present
 
Api anti patterns
Api anti patternsApi anti patterns
Api anti patterns
 
Pagination Done the Right Way
Pagination Done the Right WayPagination Done the Right Way
Pagination Done the Right Way
 
Men's views on gender diversity in the workplace 092016
Men's views on gender diversity in the workplace 092016Men's views on gender diversity in the workplace 092016
Men's views on gender diversity in the workplace 092016
 
Desperately Seeking… Something
Desperately Seeking… SomethingDesperately Seeking… Something
Desperately Seeking… Something
 

Similaire à Adding Riak to your NoSQL Bag of Tricks

Counters with Riak on Amazon EC2 at Hackover
Counters with Riak on Amazon EC2 at HackoverCounters with Riak on Amazon EC2 at Hackover
Counters with Riak on Amazon EC2 at Hackover
Andrei Savu
 
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
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門
Wen-Tien Chang
 
Scaling web applications with cassandra presentation
Scaling web applications with cassandra presentationScaling web applications with cassandra presentation
Scaling web applications with cassandra presentation
Murat Çakal
 

Similaire à Adding Riak to your NoSQL Bag of Tricks (20)

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
 
Ruby on Rails & PostgreSQL - v2
Ruby on Rails & PostgreSQL - v2Ruby on Rails & PostgreSQL - v2
Ruby on Rails & PostgreSQL - v2
 
Rack
RackRack
Rack
 
Workshop Infrastructure as Code - Suestra
Workshop Infrastructure as Code - SuestraWorkshop Infrastructure as Code - Suestra
Workshop Infrastructure as Code - Suestra
 
Counters with Riak on Amazon EC2 at Hackover
Counters with Riak on Amazon EC2 at HackoverCounters with Riak on Amazon EC2 at Hackover
Counters with Riak on Amazon EC2 at Hackover
 
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)
 
KeyValue Stores
KeyValue StoresKeyValue Stores
KeyValue Stores
 
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
Nodejs - Should Ruby Developers Care?
Nodejs - Should Ruby Developers Care?Nodejs - Should Ruby Developers Care?
Nodejs - Should Ruby Developers Care?
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
RSpec on Rails Tutorial
RSpec on Rails TutorialRSpec on Rails Tutorial
RSpec on Rails Tutorial
 
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
 
Spring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataSpring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_data
 
Padrino - the Godfather of Sinatra
Padrino - the Godfather of SinatraPadrino - the Godfather of Sinatra
Padrino - the Godfather of Sinatra
 
Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)
 
High-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and JavaHigh-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and Java
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門
 
JCR In Action (ApacheCon US 2009)
JCR In Action (ApacheCon US 2009)JCR In Action (ApacheCon US 2009)
JCR In Action (ApacheCon US 2009)
 
Scaling web applications with cassandra presentation
Scaling web applications with cassandra presentationScaling web applications with cassandra presentation
Scaling web applications with cassandra presentation
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Adding Riak to your NoSQL Bag of Tricks

  • 1. Adding Riak to your NoSQL Bag of Tricks NoSQL-NYC, October 2010 Alexander Sicular @siculars
  • 2. Riak, eh? • Dynamo inspired • Homogeneous • Single key-space • Distributed • Replicated • Predictable scaleability • Data agnostic
  • 3. Origins Show me your friends... • Amazon’s Dynamo http://www.allthingsdistributed.com/2007/10/ amazons_dynamo.html • Akamai http://www.basho.com/bios.html Paramount Home Video
  • 4. CAP Theorem http://en.wikipedia.org/wiki/CAP_theorem • Consistency • Availability • Partition tolerance Pick two? Riak says: pick two at a time. http://guide.couchdb.org/draft/consistency.html
  • 5. Homogeneous • Every node is the same • Any node can service any request • Nodes gossip on their own port
  • 6. One Ring to Rule Them All Single 160 bit key space Huh? No Sharding!
  • 7. Distributed (!= replicated) • riak is not sharded ★Considerations: • vnodes = units of -must plan maximum ring distribution size • vnodes != physical -think about number of nodes (pnodes) vnodes per pnode • vnodes map to pnodes -generally no less than 10 • data is distributed at vnodes per pnode the vnode level
  • 8. Conflict Resolution • Vector Clocks • ancestry / divergency maintained • automatic or manual resolution ★Considerations: • X-Riak-ClientId, • X-Riak-Vclock • allow_mult
  • 9. Replicated (!= distributed) • configurable replication values (“N”) • configurable consistency and availability values at read and write time - read - write - durable write
  • 10. Predictable Scaleability • How much performance per node? • Scale in both directions >bin/riak-admin >Usage: riak-admin { join | leave | backup | restore | test | status | reip | js_reload | wait-for-service | ringready | transfers }
  • 11. Data Agnostic • schemaless • data objects may be of any type • binary, text (json, xml) • use content types >curl -v -d 'this is a test' -H "Content-Type: text/plain" http://127.0.0.1:8098/riak/testBucket/testKey
  • 12. Extra Goodies • Erlang http://www.pragprog.com/titles/jaerlang/ programming-erlang • Code Architecture • basho_bench • Multiple backends • bitcask • innodb
  • 13. Code architecture • Highly modularized • riak_core • riak_kv • bitcask • erlang_js http://bitbucket.org/basho
  • 14. basho_bench • Performance profiling • highly customizable • pretty pictures • key/value store generalized https://wiki.basho.com/display/RIAK/Benchmarking+with+Basho+Bench http://pics.livejournal.com/demmonoid/pic/00001sa7
  • 15. Bitcask • Riak’s default disk backend • Write Only Log • Heavy updates will grow your footprint - Look into compaction/merging settings • Keys are cached in memory with disk offsets https://spreadsheets.google.com/ccc? key=0Ak4OBkABJPsxdEowYXc2akxnYU9xNkJmbmZscnhaTFE&hl=en&authkey=CMHw8tYO
  • 16. Speak my language? • HTTP http://wiki.basho.com/display/RIAK/REST+API • Protocol Buffers http://wiki.basho.com/display/RIAK/PBC+API • Native Erlang http://wiki.basho.com/display/RIAK/Erlang+Client +PBC http://www.zazzle.com/ speak_to_me_in_tagalog_tshirt-235376204895796392
  • 17. Ok sounds good. How do I get it? >hg clone http:// bitbucket.org/basho/riak >cd riak >make all && make rel OR if you’re on a mac: >brew install riak
  • 18. What does that get me? • Fully functional • Self contained (<3) • Default configuration -64 vnodes, “riak” cookie, N = 3
  • 19. Work... like so. • Config files http://wiki.basho.com/display/RIAK/Configuration+Files • app.config -ring_creation_size • vm.args -name, -settings
  • 20. Fire it up > bin/riak > Usage: riak {start|stop|restart|reboot| ping|console|attach} > bin/riak start
  • 21. Do Stuff! GET: > curl -v http://127.0.0.1:8098/ping > curl -v http://127.0.0.1:8098/stats > curl -v http://127.0.0.1:8098/riak/myBucket > curl -v http://127.0.0.1:8098/riak/myBucket/myKey PUT: > curl -v -X PUT -H "Content-Type: application/json" -d '{"backend": "ets"}' http://127.0.0.1:8098/riak/myBucket > curl -v -X PUT -d 'test key' http://127.0.0.1:8098/riak/ myBucket/myKey > curl -v -X POST -d 'autogen key' http://127.0.0.1:8098/ riak/myBucket
  • 22. Links • Lightweight Graphing • Practical limitations re. number of links per object • Unidirectional object linking • relationship modeling (one to one, one to many) • Returns “Content-Type: multipart/mixed;” - Library needs to be multipart aware - nodejs, formidable
  • 23. Link Walking First level depth >curl http://localhost:8098/riak/myBucket/myKey/_,_,_ Via Map/Reduce >$ curl -X POST -H "content-type:application/json" http://localhost:8098/mapred --data @- {"inputs":[["myBucket","myKey"]],"query":[{"link":{}},{"map": {"language":"javascript","source":"function(v) { return [v]; }"}}]} ^D N level depth >curl http://localhost:8098/riak/myBucket/myKey/_,_,_/_,_,_ More Info: http://blog.basho.com/2010/02/24/link-walking-by-example/ http://wiki.basho.com/display/RIAK/Links http://wiki.basho.com/display/RIAK/REST+API#RESTAPI-Linkwalking
  • 24. Map/Reduce • Functions written in either Erlang or JavaScript • Map is distributed to where the data lives • Reduce is run on the node coordinating the M/R • Erlang > JavaScript • Tweak JavaScript settings in app.conf
  • 25. M/R in Riak • An input to start from function(v, keydata, args) { • bucket if (v.values) { var ret = [], o = {}; • list of keys o = Riak.mapValuesJson(v)[0]; o.lastModifiedParsed = Date.parse(v["values"][0]["metadata"] ["X-Riak-Last-Modified"]); ★ keys > bucket o.key = v["key"]; ret.push(o); • possible link phase return ret; } else { return []; • one or more map phases }; } • (many) possible reduce phase(s) Map = SQL Where clause Reduce = SQL Aggregates (SUM, COUNT, GROUP BY)
  • 26. Pre/Post Commit Hooks • Pre Commit • Post Commit • JavaScript or Erlang • Erlang • Validation • Indexing • Modify data • Messaging • Kill writes
  • 27. Code demo • nodejs • riak-js • redis • simple post site • tags • json data passing
  • 28. Chief complaints • No index • No native sort • No increment • No full text search * *Yet ;) inc Riak Search! http://www.slideshare.net/rklophaus/riak-search-erlang-factory-london-2010
  • 29. Hybrid architectures are the future! Use tools like Redis to augment shortcomings!
  • 30. 1,456,023 Or “A Lot” • At scale, precision does not matter in practice. • Google • Twitter http://photography.nationalgeographic.com/photography/enlarge/ okavango-cape-buffalo_pod_image.html
  • 31. Google Look Ma! No exact counts!
  • 32. Twitter No Totals! No Pagination!
  • 33. Questions? Alexander Sicular @siculars

Notes de l'éditeur