Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Rolling With Riak


Published on

Overview of Riak's NoSQL distributed key/value data store by John Lynch from Rigel Group.

Published in: Technology
  • Be the first to comment

Rolling With Riak

  1. 1. (Yet-Another-NoSQL-DB) Presented By John Lynch [email_address]
  2. 2. Web App Developers ORM Focus on the App Speed of Development DB Agnostic(ish) Fixed Schema Limits design choices Migration Hell Scaling at DB layer Rails!
  3. 3. Shiny New Toys Decades of research and best practices Awesome ad-hoc query capability Zillions of vendors/tools/libraries/code Flexibility of schema-less design Ability to scale…. Web-scale
  4. 4. Web Scale <ul><li>Changing App Types </li></ul><ul><ul><li>Social </li></ul></ul><ul><ul><li>Games </li></ul></ul><ul><ul><li>Marketing / Advertising </li></ul></ul><ul><li>Freemium Business Models </li></ul><ul><ul><li>1M free => 10K paying customers </li></ul></ul>
  5. 5. NoSQL Landscape <ul><li>Pure Key/Value (Redis/Tokyo Cabinet/etc) </li></ul><ul><li>Key/Value+ (CouchDB/MongoDB/Riak) </li></ul><ul><li>BigTable Type (Hbase, HyperTable) </li></ul><ul><li>Choose wisely! No standard API. </li></ul>(Good general overview can be found here:
  6. 6. MongoDB <ul><li>Popular with Ruby community </li></ul><ul><li>Combines Key/Value with ability to do Indexed Queries </li></ul>
  7. 7. Scaling MongoDB Master, Slave, Replica Set, Replica Pair, Shard Server, Connection Pool, ack!
  8. 8. Scaling MongoDB 
  9. 9. If all you want is NoSQL… NoSQL on MySQL Leverages all MySQL skills, tools, techniques, stability, dependability If you want NoSQL + Scalability… … not so much.
  10. 10. Riak <ul><li>Developed by </li></ul><ul><li>Used on several large production sites </li></ul><ul><li>Written in Erlang </li></ul><ul><li>Distributed – Fault Tolerant </li></ul><ul><li>Buckets – Keys – Values </li></ul><ul><li>Values can be anything (json,binary,etc) </li></ul><ul><li>Ruby & Rails Client (Ripple project @ Github) </li></ul>
  11. 11. Riak speaks HTTP > curl –i http://host:8098/riak/bucket1/key1 HTTP/1.1 200 OK X-Riak-Vclock: awpcFAA== Content-Type: text/plain Content-Length: 9 Last-Modified: Wed, 01 Se… Etag: 45364657 I am a value Leverage existing HTTP infrastructure, tools, etc
  12. 12. Scaling Riak Riak Riak Riak Riak Riak Http Load Balancer Varnish (cache) Standard HTTP Protocol Rails Rails Rails Rails Rails
  13. 13. Scaling Riak (alt) Riak Rails Nginx Riak Rails Nginx Riak Rails Nginx Riak Rails Nginx Riak Rails Nginx Http Load Balancer Varnish (cache) Standard HTTP Protocol
  14. 14. Key Differentiator - Distributed <ul><li>Inspired by Amazon’s Dynamo </li></ul><ul><li>Uses consistent hashing algorithim </li></ul><ul><li>No “Master Node” </li></ul><ul><li>No single point of failure </li></ul><ul><li>Any node can service any request </li></ul><ul><li>Automatically rebalances as nodes join </li></ul><ul><li>Tunable CAP Properties </li></ul><ul><ul><li>Consistency, Availability, Partition Tolerance </li></ul></ul>
  15. 15. N R W <ul><li>N = # of copies of the data </li></ul><ul><li>R = # of nodes necessary to read </li></ul><ul><li>W = # of nodes necessary to write </li></ul><ul><li>Tunable by the application, on a per-bucket and per-query basis </li></ul>
  16. 16. <ul><li>Low Value Data (N=2 R=1 W=1) </li></ul><ul><ul><li>Logging </li></ul></ul><ul><li>Web Content (N=4 R=1 W=4) </li></ul><ul><ul><li>Maximum availability and consistency </li></ul></ul><ul><li>Financial Data (N=4 R=1 W=4 DW=4) </li></ul><ul><ul><li>DW is “Durable Write” </li></ul></ul>Riak cluster of 4 Physical Computers
  17. 17. Network Split
  18. 18. Network Split
  19. 19. Network Split
  20. 20. Map/Reduce <ul><li>Map steps run on each node </li></ul><ul><li>Final reduce runs on single node </li></ul>results = add(“albums”). map(&quot;function(v){ return [JSON.parse(v.values[0].data).title]; }&quot;, :keep => true).run
  21. 21. Links <ul><li>Riak documents can have links to other documents, each link can be “tagged” </li></ul><ul><li>Link data is separate from doc data </li></ul><ul><li>Easy URL access to walk these links </li></ul><ul><ul><li>GET /riak/artists/TheBeatles/albums,_,_/tracks,_,1 </li></ul></ul>
  22. 22. When NOT to use Riak <ul><li>Single machine </li></ul><ul><li>Small scale or bog-standard apps </li></ul><ul><li>Need rich ad-hoc indexed queries </li></ul><ul><li>Need mature tools and libraries </li></ul>
  23. 23. Any questions? (First round at Rock Bottom generously sponsored by