Mathias Meyer
Mathias Meyer

Tags

I like to think that there’s never been a more exciting time when it comes to playing with new technologies. Sure, that’s a bit selfish, but that’s just how I feel. Doing Java after I got my diploma was interesting, but it wasn’t exciting. Definitely not compared to the tools that keep popping up everywhere.

One “movement” (if you can even call it that) is NoSQL. I’ve never been particularly happy with relational databases, and I happily dropped MySQL and the like when an opportunity to work with something entirely new came up. Since it’s my own project I’m not putting anything at risk, and I don’t regret taking that step. We’re working with two members of the NoSQL family in particular, CouchDB and Redis.

Last week people interested in and people working with and on these new and pretty fascinating tools came together for the first NoSQL meetup in Berlin. I talked about Redis, and before I keep blabbering on about it, here are my slides. The talks have been filmed, so expect an announcement for the videos soon-ish.

I was up against a tough competition, including CouchDB, Riak and MongoDB (but we’re all friends, no hard feelings). During my talk, I might’ve overused the word awesome. But after all the talks were over, it hit me: Redis is awesome. It seriously is. Not because it does a lot of things, is distributed, written in Erlang (it’s written in old-school, wicked fast C), has support for JSON (though that’s planned), and all that stuff. No, it’s awesome because it does only a very small set of work for you, but it does it extremely well, and wicked fast. I don’t know about you, but I like tools like that. I took a tour of the C code last week, and even though my skills in that area are a bit rusty, it was quite pleasant to read, and easy to follow the flow.

I like Redis, and while I don’t ask you to love it too, do yourself a favor and check it out. It gives Memcached a serious run for its money. Everyone loves benchmarks, and I do to, but I’m careful not reading too much into them. I ran Redis and Memcached through their paces, using the available Ruby libraries. I tried both the C-based and and Ruby-based version for Memcached, and the canonical Ruby version for Redis. It’s like a cache, with sugar sprinkled on top.

Without putting out any numbers, let me just say that, first it’s a shame Rails is shipped with the Ruby version of the Memcached library, because it is sloooow. Okay not so slow you should be worried, but slower than the competition. Second, Redis clocks in right in the middle between both Memcached libraries. While it’s faster than memcache-client, it’s still a bit slower than memcached. Did I mention that the library for Redis is pure Ruby? Pretty impressive, especially considering what you get in return. Sit back for a moment, and think about how much work went into Memcached already, and how young Redis still is. Oh the possibilities.

Redis is more than just a key-value store, it’s a lifestyle. No wait, that’s something different. But it still requires you to think differently. Shouldn’t be a surprise really, most of the new generation of data stores do. It takes any data you give to it, and you’re good to go as long as it fits into your memory. Let me tell you, that’s still a lot of data. Salvatore is constantly working on new features for Redis, so keep an eye on its GitHub repository. If you thought that pushing and popping elements atomically off lists was cool, there might be a big warm surprise for you in the near future.

I first came across it using Nanite, where it’s used to store the state of the daemon cluster. Running it through its paces in preparation for the talk I realized how underused it is. For our use case, Redis is the perfect place to store stuff like history of system data, e.g. CPU usage, load, memory usage and the like. It’s also a great fit for a worker queue, but since we have RabbitMQ in place, there’s no need for that.

When you look at it closely, there’s heaps of uses for Redis. Chris Wanstrath wrote about how he used it writing hurl, and Simon Willison also published a love letter to Redis, there’s also more info on how you use it with the Ruby library over at the EngineYard blog, and James Edward Grey published a whole serious on how to install, setup and use Redis with Ruby. Just like CouchDB I want to put Redis to more uses in the future. That doesn’t mean I’m looking to find a problem for a solution, it just means that when I have a problem I’m gonna consider my options, and Redis is one of them. It’s a perfect mix between a simple yet insanely speedy data store, but with the little twist that is Redis’ way of persisting data.