Mar
11
Introducing Redis: a fast key-value database
By Antonio Cangiano. Filed under Erlang, Python, Ruby
One of the many advantages of having remarkable friends is learning quite early on about their most ambitious and interesting projects. Today, I’m going to talk about Redis, one such project that my friend Salvatore “antirez” Sanfilippo started.
Redis (REmote DIctionary Server) is a key-value database written in C. It can be used like memcached, in front of a traditional database, or on its own thanks to the fact that the in-memory datasets are not volatile but instead persisted on disk. As such it’s also very similar to memcachedb, though unlike the latter, Redis provides you with the ability to define keys that are more than mere strings (as well as being able to handle multiple databases). At this early stage (beta 6), lists, sets and even basic master-slave replication are supported, but more features are in the works (including compression).
Despite being a very young project, it already has client libraries for several languages: Python and PHP (by my friend Ludovico Magnocavallo), Erlang (by my friend Valentino Volonghi of Adroll.com), and Ruby by Ezra Zygmuntowicz. Except for Ezra, who should no doubt be a familiar name to most, Redis is pretty much an Italian product; and like other Italian products such as Lamborghini and Ferrari, this schema-less database is amazingly fast.
On an entry level Linux box, Redis has been benchmarked performing 110,000 SET operations, and 81,000 GETs, per second. As you can imagine, fast performance is one of the major goals of this project, and having chosen linked lists to have at the core of Redis’ implementation allows it to perform PUSH operations in O(1).
Salvatore has implemented a Twitter clone known as Retwis to showcase how you can use Redis and PHP to build applications without the need for a database like MySQL or any SQL query. He used PHP in order to reach a wide audience, but of course you can do the same with Python, Ruby or Erlang. The remarkable thing is how fast this clone is. According to Apache’s benchmark data, Salvatore’s commodity server (a Pentium D which is also running several large sites) could handle 150 pageviews per second (6 milliseconds each) for each of the 50 concurrent users. This was possible while using the grand total of 1 MB of RAM for the database. Of course, this is just a quick benchmark and there wasn’t a huge deal of data in the database either, but the responsiveness was very impressive nevertheless.
Salvatore will be publishing a beginner’s article based on the PHP Twitter clone he wrote, soon. It should appear on this wiki page where the code is already available, within the next couple of days. You can follow Salvatore and the evolutions of this project through his Twitter account. So check Redis out and (especially if you have experience with key-value databases) don’t forget to provide your feedback and/or contribute to the project.
Related Articles:
- TextMate bundle for DB2
- Startup Interviews: Zooppa.com
- Serving Django Static Files through Apache
- Benchmarking Tornado vs. Twisted Web vs. Tornado on Twisted
- DB2 support for Ruby/Rails turns 2.0
If you enjoyed this post, then make sure you subscribe to our RSS Feed.
Comments
20 Responses to “Introducing Redis: a fast key-value database”
Leave a Reply























As fast as a Ferrari, as easy to digest as a pizza
Thanks for telling about the project.
Is there any kind of query language support or one can only get value by a key?
Alexis: hello, there is no query language but you can do more than asking for the value of a key. For example the “KEYS pattern” command will return all they keys matching a given pattern. LRANGE will return a range of a list, and SINTER will return the intersection between Set values stored at two or more keys and so on.
I’m working on ways to allow sorting right now.
[...] Introducing Redis: a fast key-value database Currently / Submitted 4 seconds ago by jsuggs Tags: databases! technology! Redis (REmote DIctionary Server) is a key-value database written in C. It can be used like memcached, in front of a traditional database, or on its own thanks to the fact that the in-memory datasets are not volatile but instead persisted on disk. As such it’s also very similar to memcachedb, though unlike the latter, Redis provides you with the ability to define keys that are more than mere strings (as well as being able to handle multiple databases). At this early stage (beta 6), lists, sets and even basic master-slave replication are supported, but more features are in the works (including compression). [...]
Antonio, thanks for sharing!
When I get a project that I’ll need to use a key-value store, it will be the hardest decision ever: Tokyo-cabinet, scalaris, CouchDB, Dynomite, Ringo and now Redis. And of course, this is just for start.
[...] March 11, 2009 Antonio Cangiano wrote: [...]
[...] Vía Zend and the Art of Programming. [...]
[...] Salvatore Sanfilippo es el creador de este peculiar sistema de base de datos y para demostrar sus bondades ha creado un clon de Twitter utilizando PHP y reemplazando MySQL por su Redis. El proyecto se llama Retwis y pronto lanzará una artículo detallando el proceso de creación y desarrollo de la misma. [...]
Awesome!
Will definitely have a serious play with it.
Thanks for “broadcasting” these news, Italian achievements too often fall out of my poor radar :-/
Wow, you reinvented Berkeley DB? Cool!
How does in come into play with moneta?
[...] http://antoniocangiano.com/2009/03/11/introducing-redis-a-key-value-database/ : Redis inaugure une nouvelle catégorie : la base de données de la semaine [...]
[...] Introducing Redis by Antonio Cangiano [...]
[...] So far I’ve been quite pleased with Redis, especially given how new it is. It’s quite fast, is network accessible, atomic operations make locking unnecessary, supports sortable and sliceable [...]
BerkeleyDB lives on harddisks, Redis lives in the memory. Quite a difference.
Thanks for “broadcasting” these news, Italian achievements too often fall out of my poor radar
Alexis: hello, there is no query language but you can do more than asking for the value of a key. For example the “KEYS pattern” command will return all they keys matching a given pattern. LRANGE will return a range of a list, and SINTER will return the intersection between Set values stored at two or more keys and so on.
I’m working on ways to allow sorting right now.
How does in come into play with moneta ..thanks
t’s quite fast, is network accessible, atomic operations make locking unnecessary,
Thanks for telling about the project.