Sidekiq: running sidekiq on a different redis server/namespace

Created on 26 Apr 2012  ·  14Comments  ·  Source: mperham/sidekiq

This is what I have in config/initializers/sidekiq.rb

Sidekiq.configure_client do |config|
  config.redis = { url: "redis://myserver.com:6379/0", namespace: "my-workers" }
end

But when I run bundle exec sidekiq or bundle exec sidekiq -r . it keeps using redis://localhost:6379/0

2012-04-26T04:20:34Z 1556 TID-owjeurtnw INFO: Booting sidekiq 1.1.3 with Redis at redis://localhost:6379/0
2012-04-26T04:20:34Z 1556 TID-owjeurtnw INFO: Running in ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.3.0]

I can't seem to find any resource in the wiki about setting up sidekiq to use Rails initializers and workers.

Most helpful comment

The 'client' configuration tells Sidekiq where to push messages to(i.e: it tells Foo.perform_async where the message should go), where as the 'server' tells the 'sidekiq' executable where to pull messages from. Although, I think 'server' is a poor choice of name, it is not really a 'server' in the classical sense, it is a looping client reading from redis.

All 14 comments

You need to configure both the client and server. Does this help?

https://github.com/mperham/sidekiq/wiki/Advanced-Options

Ah, that didn't jump out of the page easily. Sorry about that. And thanks for the clarification. I'm not sure why there's a need to configure the client and server URLs separately, though.

The 'client' configuration tells Sidekiq where to push messages to(i.e: it tells Foo.perform_async where the message should go), where as the 'server' tells the 'sidekiq' executable where to pull messages from. Although, I think 'server' is a poor choice of name, it is not really a 'server' in the classical sense, it is a looping client reading from redis.

I'm not seeing it on that page, is it basically putting this in an initializer after adding redis-namespace gem?

Sidekiq.configure_server do |config|
  config.redis = { url: 'redis://redis.example.com:7372/12', namespace: "foo" }
end

Sidekiq.configure_client do |config|
  config.redis = { url: 'redis://redis.example.com:7372/12', namespace: "foo"}
end

Schneems, if you're on Heroku, Sidekiq has a dead simple way of configuring the Redis URL using the ENV. See the Using Redis wiki page.

On Jul 26, 2017, at 18:30, Richard Schneeman notifications@github.com wrote:

I'm not seeing it on that page, is it basically putting this in an initializer?

Sidekiq.configure_server do |config|
config.redis = { url: 'redis://redis.example.com:7372/12', namespace: "foo" }
end

Sidekiq.configure_client do |config|
config.redis = { url: 'redis://redis.example.com:7372/12', namespace: "foo"}
end

You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

I am, but i'm running into conflicts with two apps locally that are both using the default sidekiq namespace and queue. Needed to split it out https://github.com/codetriage/codetriage/pull/598

Yep, you need to add the Redis-namespace gem to your bundle and add the namespace option to the Redis hash as in your example.

On Jul 26, 2017, at 19:35, Richard Schneeman notifications@github.com wrote:

I am, but i'm running into conflicts with two apps locally that are both using the default sidekiq namespace and queue. Needed to split it out codetriage/codetriage#598


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

why sidekiq gem return this error i follow up your answer
i add the Redis-namespace gem to gem file

/Users/mac/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/redis-namespace-0.4.3/lib/redis/namespace.rb:128:in `<class:Namespace>': uninitialized constant Redis::Client::ALIASES (NameError)

@mperham

That looks like a better question for stack overflow or for the redis-namespace gem github issues.

i need to run sidekiq as a standalone server to perform heavy background job can you provide details how to achieve this.

@mperham @schneems Do you guys think going over using multiple redis databases for local development is a better alternative than having to add the redis-namespace dependency to all my projects using sidekiq?

EDIT: Just found out databases in redis are identified by numbers, not names, so it complicates its usage for teams. Namespaces seems the way to go.

@dportalesr +1 for adding a simple namespace option so we don't have to use the redis-namespace gem just to run a lot of microservices using Sidekiq on one shared Redis server! @mperham would that be hard to implement?

The namespace is the “db” Redis option. Learn it and use it.

On Nov 26, 2019, at 11:09, Isac notifications@github.com wrote:


@dportalesr +1 for adding a simple namespace option so we don't have to use the redis-namespace gem just to run a lot of microservices using Sidekiq on one shared Redis server! @mperham would that be hard to implement?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

@mperham I do know and use the "db" Redis option. This requires different connection strings for each client, etc and in cases where you aren't able to configure Redis server yourself it would be helpful

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidcelis picture davidcelis  ·  3Comments

mperham picture mperham  ·  4Comments

homanchou picture homanchou  ·  3Comments

nikhilm492 picture nikhilm492  ·  4Comments

jlecour picture jlecour  ·  4Comments