10

I would like Celery to build on Redis rather than the default RabbitMQ.

The Celery documentation explains:

Configuration is easy, just configure the location of your Redis database:

BROKER_URL = 'redis://localhost:6379/0'

Where the URL is in the format of:

redis://:password@hostname:port/db_number

all fields after the scheme are optional, and will default to localhost on port 6379, using database 0.

However, I have Redis set up NOT to listen to a port, but instead to listen to a socket.

Is there a URI scheme to support this?

7
  • just curious, whats the matter with redis not listening to a local port ? Commented Apr 22, 2013 at 18:20
  • Then the port is open to the Internet... Commented Apr 22, 2013 at 18:32
  • thats not correct you can bind redis to 127.0.0.1 and make it accessible only to localhost or you can create firewall rules to restrict access only to a set of ip addresses. Commented Apr 22, 2013 at 18:39
  • 2
    @TommasoBarbugli: While that is correct, and they remain my fallback plans if I can't get a simple answer to this question, using a socket is ALSO 50% faster in throughput. If I don't need to use TCP, avoiding it is a security AND a performance win. Commented Apr 22, 2013 at 23:49
  • thats just a benchmark, celery is not going to make 100k queries per second to redis using a single worker machine (praise to you and your hardware if you can make it!) if you bind redis to TCP localhost you are not going to loose much. Commented Apr 23, 2013 at 10:58

2 Answers 2

21

Redis sockets are available since Celery 1.3. The syntax is:

BROKER_URL = 'redis+socket:///tmp/redis.sock'

If you want to use a specific database:

BROKER_URL = 'redis+socket:///tmp/redis.sock?virtual_host=1'

The documentation is not up-do-date, but you can check this issues for more details:

Sign up to request clarification or add additional context in comments.

1 Comment

What about the url for the celery result backend?
1

The celery redis broker does not support socket connection, TCP connections is the only supported way at the moment.

I found this project, celery-redis-unixsocket on github after some googling. You might have a look if that works for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.