- Making the Decision
In any event, I’ll not bore you with all the details but we chose Riak. We originally chose it because we felt it would be easy to manage as our data volume grew as well as because published benchmarks looked very promising, we wanted something based on the dynamo model, adjustable CAP properties per “bucket”, speed, our “schema”, data volume capacity plan, data model, and a few other things.
The primary programming language for our project is Scala. There is no reasonable scala client at the moment that is kept up to date for Riak so we use the Java client.
We are running our application (a rather interesting business analytics platform if I do say so myself) on AWS using Ubuntu images.
We do all of our configuration management, cloud instance management, monitoring harnesses, maintenance, EC2 instance management, and much more with Opscode Chef. But, that’s a whole other story.
We are currently running Riak 1.0.1 and will get to 1.0.2 soon. We started on 0.12.0 I think it was... maybe 0.13.0. I’ll have to go back and check.
On to some of the learning (and mistakes)
Up and Running - Getting started with Riak is very easy, very affordable, and covered well in the documentation. Honestly, it couldn't be much easier. But then... things get a bit more interesting.
REST ye not - Riak allows you to use a REST API over HTTP to interact with the data store. This is really nice for getting started. It’s really slow for actually building your applications. This was one of the first easy buttons we de-commissioned. We had to move to the protocol buffers interface for everything. In hind sight this makes sense but we really did originally expect to get more out of the REST interface. It was completely not usable in our case.
Balancing the Load - Riak doesn’t do much for you when it comes to load balancing your various types of requests. We settled, courtesy of our crafty operations team on an on application node haproxy to shuttle requests to and from the various nodes. Let me warn you. This has worked for us but there be demons here! The configuration details of running HA proxy to Riak are about as clear as mud and there isn’t much help to be found at the moment. This was one of those moments over time that I really wished for the client to be a bit smarter.
Now, when nodes start dying, getting to busy, or whatever might come up you’ll be relying on your proxy (haproxy or otherwise) to handle this for you. We don’t consider ourselves done at all on this point but we’ll get there.
Link Walking (err.. Ambling) - We modeled much of our early data relationships using link walking. The learning? S-L-O-W. Had to remove it completely. Play with it but don’t plan on using this in production out of the gate. I think there is much potential here and we’ll be returning to this feature for some less latency sensitive work I perhaps. Time will tell...
Watchoo Lookin’ for?! Riak Search - When we stared search was a separate project. But, we knew we would have a use for search in our application. So, we did everything we could to plan ahead for that fact. But, by the time we were really getting all hot and heavy (post 1.0.0 deployment) we were finding our a few very interesting things about search. It's VERY slow when you have a large result set. It's just the nature of the way it's implemented. If you think your search result set will return > 2000 items then think long and hard about using Riak's search functions for your primary search. This is, again, one of those things we’ve pulled back on quite a bit. But, the most important bits of learning were to:
- Keep Results Sets small
- Use Inline fields (this helped us a lot)
- Realize that searches run on ONE physical node and one vnode and WILL block (we didn’t really feel this until data really started growing from 100’s of 1000’s of “facets” to millions.
OMG It’s broken what’s wrong - The error codes in the early version of Riak we used were useless to us and because we did not start w/ an enterprise support contract it was difficult sometimes to get help. Thankfully, this has improved a lot over time.
Mailing List / IRC dosey-do - Dust off your IRC client and sub to the mailing list. They are great and the Basho Team takes responding there very seriously. We got help countless times this way. Thanks team Basho!
I/O - It’s not easy to run Riak on AWS. It loves I/O. To be fair, they say this loud and clear so that’s my problem. We originally tried fancy EBS setup to speed it up and make it persistent. In the end we ditched all that and went ephemeral. It was dramatically more stable for us overall.
Search Indexes (aka Pain) - Want to re-index? Dump your data and reload. Ouch. Enough said. We are working around this in a variety of ways but I have to believe this will change.
Basho Enterprise Support - Awesome. These guys know their shit. Once you become an enterprise customer they work very hard to help you. For a real world production application you want Enterprise support via the licensing model. Thanks again Basho!
The learning curve - It is a significant change for people to think in an eventually consistent distributed key value or distributed async application terms. Having Riak under the hood means you NEED to think this way. It requires a shifted mindset that, frankly, not a lot of people have today. Build this fact into your dev cycle time or prepare to spend a lot of late nights.
Epiphany - One of the developers at work recently had an epiphany (or maybe we all had a group epiphany). Riak is a distributed key value data store. It is a VERY good one. It’s not a search engine. It’s not a relational database. It’s not a graph database. Etc.. etc.. Let me repeat. Riak is an EXCELLENT distributed key value data store. Use it as such. Since we all had this revelation and adjusted things to take advantage of the fact life has been increasingly nice day by day. Performance is up. Throughput is up. Things are scaling as expected.
In Summary - Reading back through this I felt it came off a bit negative. That's not really fair though. We're talking about nearly a year of learning. I love Riak overall and I would definitely use it again. It's not easy and you really need to make sure the context is correct (as with any database). I think team Basho is just getting started but are off to a very strong start indeed. I still believe Riak will really show it's stripes as we started to scale the application. We have an excellent foundation upon which to build and our application is currently humming along and growing nicely.
I could not have even come close to getting where we are right now with the app we are working on without a good team as well. You need a good devops-like team to build complex distributed web applications.
Lastly and this is the real summary, Riak is a very good key value data store. The rest it can do is neat but for now, I'd recommend using it as a KV datastore.
I'm pretty open to the fact that even with several months of intense development and near ready product under our belt we also are only scratching the surface.
What I'll talk about next is the stack, the choices we've made for developing a distributed scala based app, and how those choices have played out.