ruby-on-rails - Does ActiveJob with Sidekiq adapter have performance issue against pure Sidekiq worker?
问题描述
I see this in Sidekiq official wiki that ActiveJob would be much slower.
But it is mentioned on Mar 2018, based on Rails 4.2 and Sidekiq 5.1.1 according to this issue, and the latest would be Rails 6 and Sidekiq 6.
Is it still this case that pure Sidekiq worker would be much suggested than ActiveJob with Sidekiq adapter?
解决方案
I prepared a simple benchmark: https://github.com/mpan-wework/sidekiq-benchmark/actions?query=workflow%3ARSpec
CreateUserJob
behaves like Benchmark Job
"CreateUserJob-0, 1601366451612"
"CreateUserJob-last, 500, 1601366532766"
runs for 501 times
PureJob
behaves like Benchmark Job
"PureJob-0, 1601366532791"
"PureJob-last, 500, 1601366542691"
runs for 501 times
CreateUserWorker
behaves like Benchmark Worker
"CreateUserWorker-0, 1601366542695"
"CreateUserWorker-last, 500, 1601366621057"
runs for 501 times
PureWorker
behaves like Benchmark Worker
"PureWorker-0, 1601366621072"
"PureWorker-last, 500, 1601366630103"
runs for 501 times
Finished in 2 minutes 58.5 seconds (files took 1.72 seconds to load)
4 examples, 0 failures
The benchmark result is run over github actions with one postgres container as database and one redis container as cache.
Pure
job or worker only contains in-memory commands, CreateUser
job or worker will create 100 users through SQL.
0
represents the timestamp of the first job/worker to run; when every job/worker finishes, it will write its id and end time to cache, so last
represents the last job/worker.
For each type of job/worker, 501 items are enqueued.
From the data collected, PureJob
takes 9.900 seconds while PureWorker
takes 9.031 seconds; CreateUserJob
takes 81.154 seconds while CreateUserWorker
takes 78.362 seconds. Sidekiq worker is faster than ActiveJob with Sidekiq adapter, but not as much as stated.
I have not yet tested on kubernetes cluster with multiple rails and sidekiq pods, but I guess the difference would not be significant.
推荐阅读
- c# - 忽略使用 YamlDotNet 引发异常的成员
- laravel - Laravel 中的全局设置对象?
- java - 使用 Java 8 Stream 将 null 替换为 2D 字符串数组中的另一个值
- angular - 如何以 Ionic 角度将 Observable 数据传递给 PDF (pdfMake)?
- python - Word2vec:模块对象不是 callabale
- javascript - 当在 vue.js 中的特定卡片上发生点击功能时,如何应用基于书籍 ID 或卡片 ID 的样式?
- pandas - 指定列中值的密度图
- python - 通过提交测试示例来解密应用程序背后的逻辑
- python - 在 python 中导入 numpy 库时出现错误
- heroku - 如何在 Heroku 上部署使用 webrtc、peerjs 和 socketio 制作的视频聊天应用