ruby-on-rails - 事情在 sidekiq 中排队但没有在 heroku 中执行

标签 ruby-on-rails heroku sidekiq

所以在用户注册之后,我做了两件事

1) 发送欢迎邮件 2) 将他们的 facebook 个人资料图片更新到我的 s3

  if user.save

    UpdateAvatarWorker.perform_async(user.id)


    UserMailer.welcome_email(user).deliver_later unless user.email.nil?

    render json: {

      status: 200
    }
  else
    render json: { errors: user.errors.messages, status: 500 }
  end

现在在 sidekiq 网络用户界面中,我看到这些作业正在排队但未安排

这是我的配置

config/sidekiq.yml

development:
  :concurrency: 5
production:
  :concurrency: 10

config/initializers/sidekiq.rb

require 'sidekiq'
require 'sidekiq/web'

if Rails.env.production?

  Sidekiq.configure_client do |config|
    config.redis = { size: 2 }
  end

  Sidekiq.configure_server do |config|
    config.redis = { size: 10 }
  end

end

程序文件

web: bundle exec rails server -p $PORT
worker: bundle exec sidekiq -c 10 -v -t 25 -q default -q mailers

config/initializers/redis.rb

uri = URI.parse(ENV['REDISTOGO_URL']) || "redis://localhost:6379/"
REDIS = Redis.new(url: uri)

我在 heroku redis go 中使用迷你计划,它有 50 个到 redis 的连接

redistogo (redistogo-objective-72231) mini $9/month 创建 └─ 为REDISTOGO

工作人员似乎总是处于崩溃模式

➜  couch_bunny git:(master) heroku ps --app couchbunny
=== run: one-off processes (1)
run.9503 (Standard-1X): up 2018/03/31 17:20:00 +0530 (~ 41m ago): rails console

=== web (Standard-1X): bundle exec rails server -p $PORT (1)
web.1: up 2018/03/31 17:31:03 +0530 (~ 30m ago)

=== worker (Standard-1X): bundle exec sidekiq -c 10 -v -t 25 -q default -q mailers (1)
worker.1: crashed 2018/03/31 17:47:20 +0530 (~ 14m ago)

enter image description here

最佳答案

您通过 Sidekiq.configure_server 手动设置池大小为 10,并以 10 的并发启动 Sidekiq。在内部,Sidekiq 要求池至少有 concurrency + 2 连接,所以这就是错误的来源。

Mike suggests不要手动设置 size 选项,而是让 Sidekiq 来设置。对于 10 的并发,它会自动将池大小设置为 10 + 5 = 15

关于ruby-on-rails - 事情在 sidekiq 中排队但没有在 heroku 中执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49587788/

相关文章:

html - 在带有 link_to 的 ERB 中生成的 HREF 不可点击

ruby-on-rails - Controller Spec#Show Action : exoected: [Object], 得到:无错误 - RSpec 3

ruby-on-rails - 使用Sidekiq进行事件作业并获取ActiveJob::DeserializationError

node.js - 引用错误: process is not defined, Node ,Heroku

ruby-on-rails - 等待时间后 Sidekiq 排队作业

ruby-on-rails - Sidekiq 在 docker-compose 上的 127.0.0.1:6379 (Errno::ECONNREFUSED) 上连接到 Redis 时出错

ruby-on-rails - Bundler.require 不适用于我的 gem 中的 ActiveRecord

ruby-on-rails - Rails 创建方法创建重复项

heroku - 如何使用 API 将 "authorized redirect URIs"添加到 Google OAuth2?

angularjs - Heroku 上的空白页面 -mean.js Angular 应用程序