【问题标题】:Can multiple rails application use one redis for resque jobs?多个 Rails 应用程序可以使用一个 redis 来执行 resque 作业吗?
【发布时间】:2014-09-17 03:42:46
【问题描述】:

是否有一个 redis(用于后台作业)用于多个 rails 应用程序?

编辑:

如果我对所有应用程序使用相同的 redis,那么一个 redis 有许多来自不同应用程序的作业排队,这会引发应用程序的 Resque 可能处理错误作业的问题。

【问题讨论】:

  • 是的,您需要将所有应用程序指向一个特定的 redis 服务器。..
  • 是的,但是有几个来自不同应用程序的作业在 redis 中排队,并且他们有自己的 Resque 来处理这些作业。那么redis是如何区分哪个job是针对哪个应用的呢。问题是,应用程序的 Resque 可能会处理错误的工作。
  • 使用 Redis,并为每个应用使用相同的数据库编号但不同的队列名称。在您的应用中,您需要为每个应用指定队列名称

标签: ruby-on-rails-3 redis resque


【解决方案1】:

按照文档中的说明,您可以设置 Resque 以使用命名空间连接到 redis,如下所示:

Resque.configure do |config|
  # Set the redis connection. Takes any of:
  #   String - a redis url string (e.g., 'redis://host:port')
  #   String - 'hostname:port[:db][/namespace]'
  #   Redis - a redis connection that will be namespaced :resque
  #   Redis::Namespace - a namespaced redis connection that will be used as-is
  #   Redis::Distributed - a distributed redis connection that will be used as-is
  #   Hash - a redis connection hash (e.g. {:host => 'localhost', :port => 6379, :db => 0})
  config.redis = 'localhost:6379:alpha/high'
end

【讨论】:

    猜你喜欢
    • 2012-12-13
    • 2011-10-27
    • 2020-07-07
    • 2011-08-13
    • 2013-12-05
    • 2011-09-24
    • 1970-01-01
    • 2014-08-18
    • 1970-01-01
    相关资源
    最近更新 更多