Riak is an open source, highly scalable, fault-tolerant and distributed database.
Based on Amazon's Dynamo Key/Value paper and Dr Eric Brewer's CAP Theorem.
CAP theorem, states that it is impossible for a distributed computer system to simultaneously provide all three of the following guarantees:
Buckets + keys are the main way to organise user data.
Bucket is a collection of keys, with associated configuration data.
Keys can be either a string or binary, user defined or riak can generate
one.
eg 37458abc752f8413e, fancy_string or 0xDEADBEEF
Link: </riak/bucket/key>; riaktag="whatever?" X-Riak-Meta-Color: whatever?
curl -X PUT http://localhost:8091/riak/cages/1 \ -H "Content-Type: application/json" \ -H "X-Riak-Meta-Color: Pink" \ -H "Link: ; riaktag=\"contains\"" \ -d '{"room" : 101}'
Riak's default mode of operation is in a cluster.
CAP Controls: N, R and W
The extent to which data is replicated, when, and with what merge strategy and failure model, is configurable at runtime.
Riak computes a 160-bit binary hash of the bucket/key pair, and maps this value to a position on an ordered "ring" of all such values.
eg 32 partitions / 4 nodes = 8 vnodes for each nodeWrites are split across multiple nodes and only returns success if write is confirmed by N nodes.
Reads are also split across multiple nodes with the same consensus protocol.
Inconsistent read results can be repaired without user intervention (Read Repair).
Ring state is shared around the cluster by means of a gossip protocol.
Riak's Map Reduce allows richer queries over the data stored in Riak.
Can be written in Javascript or Erlang.
Spreads the processing of the query to where the data is.
Basho provides supported clients for:
Basho provides great Ruby support via the Ripple library,
https://github.com/seancribbs/ripple
It includes two namespaces:
Supports Rails 3 and greater.
Available for all good Unix systems. Instructions available on wiki.basho.com
phoenix$ curl -O http://downloads.basho.com/riak/riak-1.1.1/riak-1.1.1-osx-x86_64.tar.gz phoenix$ tar xzvf riak-1.1.1-osx-x86_64.tar.gz phoenix$ cd riak-1.1.1 phoenix:riak-1.1.1$ ./bin/riak start phoenix:riak-1.1.1$ ./bin/riak ping pong
phoenix$ curl -v http://127.0.0.1:8098/riak/books/erlang_otp_in_action * About to connect() to 127.0.0.1 port 8098 (#0) * Trying 127.0.0.1... * connected * Connected to 127.0.0.1 (127.0.0.1) port 8098 (#0) > GET /riak/books/erlang_otp_in_action HTTP/1.1 > User-Agent: curl/7.24.0 (x86_64-apple-darwin11.3.0) libcurl/7.24.0 OpenSSL/1.0.0g zlib/1.2.6 libidn/1.22 > Host: 127.0.0.1:8098 > Accept: */* > < HTTP/1.1 200 OK < X-Riak-Vclock: a85hYGBgzGDKBVIcypz/fvpHeitmMCUy5bEyOOw6f4IvCwA= < Vary: Accept-Encoding < Server: MochiWeb/1.1 WebMachine/1.9.0 (someone had painted it blue) < Link: ; rel="up" < Last-Modified: Sat, 10 Mar 2012 11:42:56 GMT < ETag: "76dfItNC7ZsSupMV0VIGZ4" < Date: Sun, 11 Mar 2012 10:15:55 GMT < Content-Type: application/json < Content-Length: 213 < * Connection #0 to host 127.0.0.1 left intact {"title":"Erlang and OTP in Action","author":"Logan Martin","summary":"Erlang is an adaptable and fault tolerant functional programming language originally designed for the unique demands of the telecom industry"} * Closing connection #0
phoenix$ curl -v http://127.0.0.1:8098/buckets/books/keys?keys=true ... < HTTP/1.1 200 OK < Vary: Accept-Encoding < Server: MochiWeb/1.1 WebMachine/1.9.0 (someone had painted it blue) < Date: Sun, 11 Mar 2012 10:42:36 GMT < Content-Type: application/json < Content-Length: 155 < * Connection #0 to host 127.0.0.1 left intact {"keys":["machine_learning_in_action","erlang_otp_in_action","programming_erlang","well_grounded_rubyist","practical_common_lisp","javascript_good_parts"]} * Closing connection #0
phoenix$ curl -v -X DELETE http://127.0.0.1:8098/riak/books/erlang_otp_in_action ... < HTTP/1.1 204 No Content < Vary: Accept-Encoding ...
What's happening?
/
#