简体   繁体   English

带有sidekiq的Rails ActiveJob Job延迟6/10秒

[英]Rails ActiveJob Job with sidekiq delaying 6/10 seconds

I am using Rails ActiveJob with Sidekiq. 我在Sidekiq中使用Rails ActiveJob。 I have a Job that is supposed to execute after 5 seconds. 我有一个应该在5秒钟后执行的作业。

UserArrivalJob.set(wait: 5.seconds).perform_later(user, planet)

Only after 5 seconds the job still hasnt ran. 仅在5秒钟后,该作业仍未运行。 When i look in the sidekiq web interface after those 5 seconds the job is there and it says: Not yet enqueued. 在那5秒钟之后,当我在sidekiq Web界面中查找时,作业就在那儿,它说:尚未入队。 After about another 6 till 10 seconds the job gets enqeued and is immediatly executed. 再过大约6到10秒后,该作业就会被确认并立即执行。 How come that there is this delay? 怎么会有这种延迟呢? When i use perform now this delay is not there. 当我现在使用表演时,此延迟不存在。

Here is my Job: 这是我的工作:

class UserArrivalJob < ActiveJob::Base
  queue_as :default

  def perform(user, planet)
    user.planet = planet
    user.save
  end
end

Read here . 在这里阅读。 Basically I think your sidekiq poller runs every 10 seconds and it picks the job when it pools. 基本上,我认为您的sidekiq轮询器每10秒运行一次,并且它在合并时选择了作业。

bcd was right. BCD是正确的。 I set the sidekiq configuration to run the poller every 2 seconds. 我将sidekiq配置设置为每2秒运行一次轮询器。

environments/development.rb / environments/production.rb 环境/development.rb/环境/production.rb

Sidekiq.configure_server do |config|
  config.average_scheduled_poll_interval = 2
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM