PPL 30 Day 2: Riak

This is part of the Peer Pressure Learning 30 series. To learn more about what in the hell that means, see the intro to the series, A Good Time To Learn.

Yet another entry in the pantheon of NoSQL data stores, Riak is inspired by Amazon’s Dynamo.

Installation

brew install riak

What up.

Resources

Why Riak Should Power Your Next Rails App

Perhaps I’m just a sucker for articles that I find in my alley, but Sean Cribb’s Why Riak Should Power Your Next Rails App seemed a pretty great overview of Riak’s features, casting it as an analog of Merb, in a world in which MongoDB plays Rails. More importantly, he covers what he considers strengths, as well as weaknesses.

The Riak Fast Track

Straight from Basho, the makers of Riak, The Riak Fast Track is a good way to get a guided start to really working with Riak. It takes about 45 minutes, and is absolutely worth your time.

What I Think I Now Know

Riak, as I mentioned, is inspired by Amazon’s Dynamo. You might not be surprised to hear, as I never took the time to play with it, that Riak is like this Dynamo thing means nothing to me.

What does mean something to me is that it is simple to scale, in that there is no concept of a master. No node is a special node. When you add nodes to a Riak cluster, you’ve just made the system more fault tolerant without forcing your application to know about this extra server that’s out there. You can freely mimic Emiril by throwing up a new node and yelling “BAM!”. In fact, I encourage you to do so. (Also, I’m a big proponent of high fives.)

The Riak data model is interesting; Riak doesn’t care what you put in there. You interact (typically) with Riak via HTTP. Yes, that means Riak has a REST API. When PUTting data in Riak, you specify a Content-type header of the type that you expect to receive back when you GET that data later. (Note: You PUT data when specifying a key, and POST when you want Riak to generate a random key.) That means you could potentially use Riak as a distributed file system. Badass.

Riak also has MapReduce capabilities built in, allowing you to perform more complex queries, beyond your typically store-and-fetch NoSQL data store paradigm. You can write your map and reduce functions using Erlang, or javascript. Also badass.

There is, of course, a Ruby client for Riak called ripple. It includes an ActiveModel-compatible ORM layer, so it can be used in your next Rails project.

As I quite subtly alluded to earlier, I think Riak is badass. As a geek, the MapReduce capabilities are supposed to cause a rush of endorphins and excited, incomprehensible utterances, but that’s not at all my favorite part. Data agnosticism and master-less replication top my list. I look forward to using Riak in an actual project. I might use it as the main data store (including storing files – I’ve already got an app in mind), and use Redis as the cache, just to be ridiculous.

I’ve still two NoSQL-style data stores on my list. From what I know about MongoDB and Cassandra already, I’m surprised to be a little disappointed to be going from Redis and Riak to Mongo and Cassandra. (Especially Cassandra… Column, SuperColumn, ColumnFamily, SuperColumnFamily, SuperWTF.)

More tomorrow. Check out Tim’s Day 2 post!