Reasons why Redis is a great option for a worker queue in Magento



Alan Kent asked on Twitter

You may know that I am partial to Redis as a worker queue for Magento.  Here are some reasons why.

  1. It is stupid simple to set up (meaning nubes and philes can both use it)
  2. It is blazing fast (it’s slow log is measured in microseconds)
  3. It does pubsub for one to many
  4. It does BLPOP for many to one
  5. It’s already supported with the Cm_Redis stuff

Things you do not get

  1. Durability
  2. Complex routing rules

When I worked on my last talk for Imagine I spent a week trying to get a fast, working implementation of ActiveMQ and Rabbit.  I looked at it and thought “this is way more complicated than it needs to be” and tried Redis.  What I spent a week working on was up and running in 4 hours, including a Java-based worker and PHP refactoring.

The HA portion is missing out of the box but I believe with Sentinal you can achieve it.  In some ways it’s like MySQL.  It’s beastly easy to get set up and running but if you need to do more you can.

undefined reference to `__sync_add_and_fetch_4′ when compiling Redis

1 Comment

I’m intending to play around with Redis a little over the next few days.  I’ve been wanting to do this for a long time and I may have found a reason for me to do it now.

So I downloaded the source onto a VM and ran make where I was getting this error

zmalloc.o: In function `zmalloc_used_memory':
/opt/redis-2.6.7/src/zmalloc.c:223: undefined reference to `__sync_add_and_fetch_4'
collect2: ld returned 1 exit status
make[1]: *** [redis-server] Error 1
make[1]: Leaving directory `/var/opt/redis-2.6.7/src'
make: *** [all] Error 2

The solution is to explicitly declare the CPU type to make this work.

[[email protected] redis-2.6.7]# uname -m

I had earlier tried setting -march=i386 since that is the CPU type that yum uses.  That didn’t work.  So I set the CPU to exactly the output of uname -m.

[[email protected] redis-2.6.7]# export CFLAGS=-march=i686
 [[email protected] redis-2.6.7]# make distclean
 [[email protected] redis-2.6.7]# make