Microsoft AppFabric vs Redis (Windows port)

The traffic of our football news syndicating website (Kick News) has been steadily growing a lot since it launched. When we redeveloped it a couple of years ago, we used an in-process cache, by creating an IQueryable extension method that uses an md5 hash of the underlying SQL query as the key. This worked reasonably well, but has it’s obvious problems, such as the caches needing to be refilled when the app pool recycles or when the server is restarted. On our busy site, this means we had to wait until the caches are full before we serve any requests or it would overload our database server, which is unacceptable. Before the site gets any busier we’re going to move to an out-of-process cache and the are 3 main options we’ve considered are Redis, Memcached and Windows Server AppFabric (there are other options however, such as Coherence). There is already quite a lot of info on Redis vs Memcached, so I won’t go into that here, but I was curious as to how AppFabric performed against Redis. 

This is an extremely limited and unscientific test, however all I was looking for was an indication and couldn’t find any data elsewhere. I used Dusan Majkic’s Windows port of Redis and the ServiceStack.Redis C# Client Library, so results might be different if I used the native version of Redis, but not enough for me to care about in this little test.

Setting up AppFabric on my test machine was a breeze and Scott Hanselman has an easy to follow guide here. To run the test, I created an ASP.Net MVC 3 project and used a System.Diagnostics.Stopwatch() to time the execution of putting and retrieving 1,000 4 byte strings and then the same with a byte array of a 115KB image. I ran the test 6 times, resetting everything in between runs and then averaged the results. There was a some variation in each run (the 4 byte string tests where all roughly the same), but I think this gives me a pretty good idea of what I wanted to know.

Set 1,000 4 byte strings:
AppFabric: 918 ms
Redis: 240 ms

Get 1,000 4 byte strings:
AppFabric: 587 ms
Redis: 137 ms

Set 1,000 115 KB byte arrays:
AppFabric: 11,195 ms
Redis: 15,812 ms

Get 1,000 115 KB byte arrays:
AppFabric: 11,976 ms
Redis: 7,163 ms

I forgot to mark them, but 1 is set and 2 is get. The conclusion I draw from this is that Redis is as fast as everyone says it is (I don’t believe AppFabric is any kind of slouch). I’m not sure why Redis ended up slower in the larger byte array set test, but there was one run when it was quite a lot slower, which would have dragged it’s average down a bit. To answer the question properly, we’d need a much better benchmarking test, but I think it’s safe to say that overall Redis is quite a lot faster overall than AppFabric, however AppFabric is very easy to setup and cluster. I think we’re going to go with Redis on a couple of dedicated Debian VMs over Memcached or AppFabric, but I think all would be a massive improvement for us over our existing in-process caching. 

Author image