Redis bundle for Symfony2

redis_screenshot

The  SncRedisBundle integrates Predis and phpredis into your Symfony2 application.

“Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain stringshasheslistssets and sorted sets.” — redis.io

At LeaseWeb we developed the LswMemcacheBundle. This is not because we do not like Redis. Maybe Redis serves a different purpose, since it has support for data structures, but is single threaded on the other hand. Having data structures could lead to better (more efficient) cache usage, while being single threaded does make a difference on the maximum amount of concurrent get and set operations (see benchmark). So without choosing for either Redis or Memcache we want to tell you about SncRedisBundle for Symfony.

The biggest differences between Redis and Memcache we found:

  • Redis has support for data structures
  • Redis has support for persistent storage
  • Redis has more features (in general)
  • php-redis and memcached are both C based clients, but php-redis is not yet in the Ubuntu repository and predis might be slower.
  • Memcache is multi-threaded and gets higher IOPS on a multi core server

If you run a high traffic PHP site, consider running Redis and/or Memcache and share your thoughts with us.

Share

6 thoughts on “Redis bundle for Symfony2”

  1. I’m using Memcache for my web server (I wrote it myself) .
    Memcache help me for improving speed and decreasing my database load.
    In my webserver I had about 10 successfully hit per second.
    But I think Memcache sometimes use more resources than it should use (CPU).
    I think in future if I will write my own cache system , it maybe faster with less resource usage,if I will have more time.

  2. @Roohollah: Are you using memcache or memcached as a client? It might be using less CPU with memcached, since that is based on libmemcached, which is highly optimized and written in C.

  3. I used memcache , but after reading your article about their comparison , I decided to try memcached .
    Thanks for your laboratory and your good research .

  4. I replaced my code with memcached. It seems memcached consume less CPU rather than of memcache.
    Thanks for your advice .

  5. Is there any close method for memcached ?
    I used close() method for memcached , but when I use quit method id memcached I see this error :
    Call to undefined method Memcached::quit()
    Is it necessary to close memcached ? (My program maybe run for half or one hour)

  6. @Roohollah: Thank you for your questions and your comments. No, you can not and do not have to close the connection AFAIK. You might even consider using persistent connections to optimize even more.

Leave a Reply

Your email address will not be published. Required fields are marked *