为什么一个ActiveJob入队操作要比另一个慢?

时间:2019-03-20 08:58:15

标签: ruby-on-rails performance sidekiq rails-activejob

我正在使用从skylight.io收集的统计信息对应用程序进行性能调整,有一点问题的页面显示,入列ActiveJob作业平均需要21毫秒(整个页面需要131毫秒)平均而言,这是加载时间的16%)。有问题的操作如下所示:

TrackVacancyPageViewJob.perform_later(vacancy.id) unless session[:session_id].present?

如果我看看其他类似的入队操作,它们会更快-大约2-5ms内。这是一个示例:

AuditExpressInterestEventJob.perform_later(
  datestamp: Time.zone.now.iso8601.to_s,
  vacancy_id: vacancy.id,
  school_urn: vacancy.school.urn,
  application_link: vacancy.application_link
)

因此,我的问题是,可能是什么原因造成的?他们都在同一个Redis实例通信,但是队列分开。队列的大小是问题吗?还是我没有考虑过其他事情?

这是我的工作:

class TrackVacancyPageViewJob < ApplicationJob
  queue_as :page_view_collector

  def perform(vacancy_id)
    vacancy = Vacancy.find(vacancy_id)
    VacancyPageView.new(vacancy).track
  end
end

class AuditExpressInterestEventJob < ApplicationJob
  queue_as :audit_express_interest_event

  def perform(data)
    AuditData.create(category: :interest_expression, data: data)
  end
end

我的sidekiq.yml在这里:

:queues:
  - [ mailers, 3 ]
  - [ queue_daily_alerts, 3 ]
  - [ email_daily_alerts, 4 ]
  - [ page_view_collector, 2 ]
  - [ performance_platform, 2 ]
  - [ google_indexing, 2]
  - [ import_school_data, 1 ]
  - [ update_vacancy_spreadsheet, 1 ]
  - [ audit_published_vacancy, 1 ]
  - [ audit_express_interest_event, 1 ]
  - [ audit_search_event, 1 ]
  - [ audit_feedback, 1 ]
  - [ audit_spreadsheet, 1 ]
update_vacancy_spreadsheet:
  :concurrency: 1
audit_published_vacancy:
  :concurrency: 1
audit_express_interest_event:
  :concurrency: 1
audit_search_event:
  :concurrency: 1
audit_feedback:
  :concurrency: 1
audit_spreadsheet:
  :concurrency: 1
audit_toc_acceptance_event:
  :concurrency: 1
mailers:
  :concurrency: 2

0 个答案:

没有答案