gates
gates

Reputation: 4603

Things are getting enqueued in sidekiq but not executing in heroku

So after a user signs up, I am doing two things

1) Sending a welcome email 2) Updating their facebook profile pic to my 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

Now in the sidekiq web UI I see that these jobs are getting enqueued but not scheduled

Here are my configurations

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

Procfile

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)

I am using mini plan in heroku redis go which has 50 connections to redis

redistogo (redistogo-objective-72231) mini $9/month created └─ as REDISTOGO

The worker always seems to be in crash mode

➜  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

Upvotes: 3

Views: 619

Answers (1)

tbuehlmann
tbuehlmann

Reputation: 9110

You're manually setting a pool size of 10 via Sidekiq.configure_server and you're starting Sidekiq with a concurrency of 10. Internally, Sidekiq requires the pool to have at least concurrency + 2 connections, so that's where the error comes from.

Mike suggests to don't set the size option manually but to let Sidekiq do it. For a concurrency of 10 it will automatically set the pool size to 10 + 5 = 15.

Upvotes: 1

Related Questions