Update (28th April 2009) – Added Tokyo Tyrant
What is Redis?
Briefly, Redis is a key-value store that stores the values to disk periodically instead of after every set.
What is Tokyo Tyrant?
Tokyo Tyrant is similar to Redis – a key-value store.
This is a brief comparison of the performance of Redis and MySQL. It is not very thorough and is only to be used as an indication as to whether Redis may be worth your further investigation.
After a brief search I failed to find any performance comparisons of Redis and MySQL to determine if it was even worth my time looking at Redis. I appreciate they are very different beasts but in our database we have a lot of data that would fit very nicely into a key-value store.
So, the question I am trying to answer is “roughly how much performance can we gain from using Redis for storing simple data instead of MySQL?”. Then it is up to you to look at all the differences and decide whether it is worth pursuing a switch to Redis.
Note: I will be looking at other key-value stores in the near future :-)
The two tests performed are:
- Using 2 threads: set X items with the keys/values being consecutive numbers
- Using 2 threads: randomly get these items Y times
- EC2 small instance.
- Default install of MySQL with a single InnoDB table for storing keys and values.
- Default make of Redis.
- Small Java benchmark programs sitting on the same box
The numbers in these files are not the exact numbers I used (apart from using two client threads in both tests)
Redis (In-memory only)
11,200 sets/second. (3.7x MySQL)
9,840 gets/second. (2.1x MySQL)
Tokyo Tyrant (Writing to disk)
9,030 sets/second. (3.0x MySQL)
9,250 gets/second. (2.0x MySQL)
Key-value stores are generally going to be faster than MySQL. They (generally) provide less functionality in the way of querying arbitrary columns and ACID compliance. This translates into faster performance on gets/sets.
Once again, it is worth pointing out that this is a very simple benchmark. My suspicion is that when you have lots of cross updates going on then Redis/Tyrant will have a greater performance boost over MySQL – but at the cost of transactionality.
My suspicion is that as the technology matures we are going to start seeing a big shift towards using key-value stores as the first port of call for data storage for websites. I expect it won’t be long before we start seeing hosts offering LAKP (Linux, Apache, a key-value store, PHP) as well as the more traditional LAMP offerings.
I would love to hear from anyone with real world experience and numbers of switching over to Redis… until I have some of my own to share anyway :)