Wednesday, February 17, 2010

Redis, and why I love it

Redis is a relatively new entry to the 'NoSQL' movement that I've been playing with. It is a in-memory key/value store server, and stands for REmote DIctionary Server. You can think of it as a reverse memcached/MySQL store, that first stores in memory then serializes to disk when it gets a chance. If you've worked with higher level languages, like Python, you know how handy dictionaries are. You can store whatever you want in them in one place and retrieve the data somewhere else. Redis is a dictionary server with some very nice built-in primitives and functions. It has lists, sets, sorted-sets and atomic operations to operate on those. Redis makes implementing things like a worker queue using the RPOPLPUSH function trivial, and that is just the beginning.

What's even better is the code is in very clean C, and the relatively small size (~10k LOC) makes it easy to read and study. There are plenty of clients (C, Python, Ruby, PHP, etc) which makes this a nice drop in to almost anywhere in your stack.



I was thinking of implementing something like GFS with it - using Redis to look up the location of a file on a NFS server. For scaling horizontally, Redis supports master/slave replication out of the box. Add a consistent hash on a filename with one master server for writes, and multiple slaves for reads and you're in business.




This is just the tip of the iceberg. There are some many uses for Redis. I look forward to working more with it!

No comments:

Post a Comment