在 Sidekiq 中使用多个 Redis 服务器 [英] Use multiple Redis servers in Sidekiq
问题描述
我正在使用 Sidekiq
将后台作业处理到我们的一个轨项目.我们想使用位于不同位置的不同 Redis 服务器将 ReportDB
与其他后台处理作业分开.
根据Sidekiq config wiki,我们可以像这样配置
config/initializers/sidekiq.rb
Sidekiq.configure_server 做 |config|config.redis = {:url =>'redis://redis.example.com:7372/12', :namespace =>'我的命名空间' }结尾Sidekiq.configure_client 做 |config|config.redis = {:url =>'redis://redis.example.com:7372/12', :namespace =>'我的命名空间' }结尾
但是如何初始化与多个 redis 服务器的连接?
Sidekiq 2 不支持多个 Redis 服务器,升级到今天刚刚发布的 sidekiq 3 并添加了您需要的新客户端分片功能.
来自:Sidekiq 3 发行说明><块引用>
客户端分片
Sidekiq 2.x 有一个可扩展性限制:一台 Redis 服务器.在实践中在良好的硬件上,限制大于每秒 5000 个作业,因此对大多数这没什么大不了的,但一些更强烈的 Sidekiq 用户是达到那个极限.更新的 (Sidekiq 3) Sidekiq::Client API 允许您指定要使用的 Redis 连接池,而不是假设之前的 Sidekiq.redis 全局池,允许你定位不同类型的作业到不同的 Redis 服务器.现在您可以缩放Sidekiq 到无穷大!
API 几乎完全向后兼容:唯一的突破变化在于客户端中间件.请参阅升级说明了解更多信息细节.
===
还要看看答案 - 使用 sidekiq 处理两个单独的 redis 实例?
I am using Sidekiq
to process background jobs into one of our
Rails project. We want to use a different Redis server located at different location to sepearate out ReportDB
with other background processing job.
According to Sidekiq config wiki we can configure like
config/initializers/sidekiq.rb
Sidekiq.configure_server do |config|
config.redis = { :url => 'redis://redis.example.com:7372/12', :namespace => 'mynamespace' }
end
Sidekiq.configure_client do |config|
config.redis = { :url => 'redis://redis.example.com:7372/12', :namespace => 'mynamespace' }
end
But how can I initialise connection to multiple redis server?
Sidekiq 2 doesn't support multiple Redis servers, upgrade to sidekiq 3 which released just today and adds the new client sharding feature that you need.
From: Sidekiq 3 Release Note
Client Sharding
Sidekiq 2.x has a scalability limit: one Redis server. In practice the limit is greater than 5000 jobs per second on good hardware so to most it wasn’t a big deal but some of the more intense Sidekiq users were hitting that limit. An updated (Sidekiq 3) Sidekiq::Client API allows you to specify a Redis connection pool to use, rather than assuming the Sidekiq.redis global pool previously, allowing you to target different types of jobs to different Redis servers. Now you can scale Sidekiq to infinity and beyond!
The API is almost entirely backwards compatible: the only breaking change is in client-side middleware. See the upgrade notes for more detail.
===
Also take a look at the answer for - Work with two separate redis instances with sidekiq?
这篇关于在 Sidekiq 中使用多个 Redis 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!