Sidekiq处理的工作还不错(一夜之间完成了30个工作)。今天早上,它完全关闭了对队列的处理(现在多达28个作业)。
在Heroku上运行(1 Standard-2 x Web Dyno,1 Standard-1 x Worker Dyno)。
Procfile (在这里,我在找到要配置的文档时遇到了最大的困难)
web: bundle exec puma -C config/puma.rb
worker: bundle exec sidekiq -e production -C config/sidekiq.ymlsidekiq.yml
development:
:concurrency: 5
production:
:concurrency: 20
:queues:
- ["default", 1]
- ["mailers", 2]sidekiq.rb
if Rails.env.production?
Sidekiq.configure_client do |config|
config.redis = { url: ENV['REDIS_URL'], size: 2 }
end
Sidekiq.configure_server do |config|
config.redis = { url: ENV['REDIS_URL'], size: 20 }
Rails.application.config.after_initialize do
Rails.logger.info("DB Connection Pool size for Sidekiq Server before disconnect is: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}")
ActiveRecord::Base.connection_pool.disconnect!
ActiveSupport.on_load(:active_record) do
config = Rails.application.config.database_configuration[Rails.env]
config['reaping_frequency'] = ENV['DATABASE_REAP_FREQ'] || 10 # seconds
# config['pool'] = ENV['WORKER_DB_POOL_SIZE'] || Sidekiq.options[:concurrency]
config['pool'] = 16
ActiveRecord::Base.establish_connection(config)
Rails.logger.info("DB Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}")
end
end
end
end另外,对于队列中的所有作业(默认,mailers),是否可以让Sidekiq运行这些作业?
更新
我已经把错误范围缩小到Heroku工人身上了。重新启动后,工人很快就会崩溃。
第一个错误与Sidekiq没有产生足够的连接有关(Redis需要22,我已经将限制设置为20)。
现在,我得到了以下错误:
Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?我正在通过Heroku运行PG霍比。它的连接限制是20。这是问题的根源吗?
发布于 2018-04-19 15:02:17
经过两天的冒险,答案被发现多亏了this SO question。希望这有助于SEO为未来的旁观者。
我将sidekiq.rb文件更改为
sidekiq.rb
require 'sidekiq/web'
Sidekiq.configure_server do |config|
ActiveRecord::Base.configurations[Rails.env.to_s]['pool'] = 30
end
if Rails.env.production?
Sidekiq.configure_server do |config|
config.redis = { url: ENV["REDISTOGO_URL"]}
end
Sidekiq.configure_client do |config|
config.redis = { url: ENV["REDISTOGO_URL"]}
end
end然后,我更新了我的sidekiq.yml
sidekiq.yml
queues:
- default
- mailers
:verbose: false
:concurrency: 5 # Important to set depending on your Redis provider
:timeout: 8 # Set timeout to 8 on Heroku, longer if you manage your own systems.注意:还有一个选项,可以在初始化程序文件中省略if语句中的所有内容。正如Sidekiq的创建者所说,您可以将heroku配置设置为:
heroku config:set REDIS_PROVIDER=REDISTOGO_URL
然后Sidekiq会找出剩下的。
https://stackoverflow.com/questions/49882362
复制相似问题