af83

Which PHP Library to use with Redis? The Benchmark

So, after the lively discussion on the previous post on this matter, I decided to go and get more data driven.

I whipped up a small benchmark,it is not very scientific, and only tests very few features.

But ones you are likely to use, some gets some sets, and an evil keys *.

You can find the code here, so you can run it on your own:

https://github.com/AF83/redisent/blob/redis2/tests/Benchmark.php

If your results are considerably different, please share them…

Basically what I go was in comparison to the phpredis extension:

  1. redisent was 50% slower and had a 25% larger memory footprint
  2. redisentwrap was around 65% slower and had a 25% larger memory footprint
  3. predis was was around 300% slower and has a 200% larger memory footprint.

We have seen that tweaking the socket buffer size can get redisent to have basically the same performance as the extension. But we need to discover what are the optimal values. They may need to change for different workloads.

I did not test Rediska as the API is so much different, and this is just a real quick and dirty bench. But considering the general bloat there… I would be very much surprised if it were faster then predis.

People love Redis because it is blazing fast. So you should take a hard look at these numbers, and run your own tests before choosing a Redis library. The differences are quite imporant.

Predis has some nice features, and it is probable you might not always need raw speed (that is you are not going to do thousands of reads/writes in a single script execution) so again, this does not mean you should not consider it.

phpredis still has its kinks, and I hope they will throw away the craziness. Even if they have to break the existing API.

I started adding a compatibility layer to redisent so you could use either (just choosing by your ability to compile extensions therefor).

My Raw results:

php Benchmark.php phpredis 5000 1000 5 >> result.log
php Benchmark.php redisent 5000 1000 5 >> result.log
php Benchmark.php redisentwrap 5000 1000 5 >> result.log
php Benchmark.php predis 5000 1000 5 >> result.log

result.log:

-- Bottom Line for phpredis: Tests completed in 2.979605 seconds in average, with 1.05 mb memory usage
-- Bottom Line for redisent: Tests completed in 4.457145 seconds in average, with 1.31 mb memory usage
-- Bottom Line for redisentwrap: Tests completed in 4.892705 seconds in average, with 1.31 mb memory usage
-- Bottom Line for predis: Tests completed in 11.707525 seconds in average, with 3.15 mb memory usage

blog comments powered by Disqus