-
In Sidekiq Ent 7, you can configure a rate limiter, which is described as cluster-safe. It accepts either a If you pass a Sidekiq::Limiter.redis = { nodes: ["redis://localhost:6379"] }
> ArgumentError: unknown keyword: :nodes Which leads me to think I need to pass my own Sidekiq::Limiter.redis = ConnectionPool.new(size: 5) do
RedisClient.cluster(nodes: ["redis://localhost:6379"], size: 5).new_client
end But I feel that means doubling up on pools - both What's the best way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Right, the redis config assumes you want a pool of basic redis-client instances. Sidekiq isn't cluster-compatible so Put this monkeypatch at the top of your app's initializer with the simple Hash config below it and let me know if it solves your problem. module Sidekiq
class RedisClientAdapter
def initialize(options)
opts = client_opts(options)
@config = if opts.key?(:sentinels)
RedisClient.sentinel(**opts)
elsif opts.key?(:nodes)
# Sidekiq does not support Redis clustering but Sidekiq Enterprise's
# rate limiters are cluster-safe so we can scale to millions
# of rate limiters using a Redis cluster.
# Sidekiq::Limiter.redis = { nodes: [...] }
RedisClient.cluster(**opts)
else
RedisClient.config(**opts)
end
end
end
end
Sidekiq::Limiter.redis = { nodes: ["redis://localhost:6379"] } |
Beta Was this translation helpful? Give feedback.
Right, the redis config assumes you want a pool of basic redis-client instances. Sidekiq isn't cluster-compatible so
Sidekiq::Config::redis=
doesn't allow:nodes
but Sidekiq::Limiter needs a spot of logic to allow cluster-compatibility.Put this monkeypatch at the top of your app's initializer with the simple Hash config below it and let me know if it solves your problem.