Ruby-on-rails delay_jobs vs resque vs beanstalkd?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4808351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 00:12:06  来源:igfitidea点击:

delayed_jobs vs resque vs beanstalkd?

ruby-on-railsredisresquebeanstalkd

提问by rafamvc

Here is my needs:

这是我的需求:

  • Enqueue_in(10.hours, ... ) (DJ syntax is perfect.)
  • Multiply workers, concurrently. (Resque or beanstalkd are good for this, but not DJ)
  • Must handle push and pop of 100 jobs a second. (I will need to run a test to make sure, but I think DJ can't handle this many jobs)
  • Enqueue_in(10.hours, ... )(DJ 语法很完美。)
  • 同时增加工人。(Resque 或 beanstalkd 对此有好处,但不是 DJ)
  • 必须每秒处理 100 个作业的推送和弹出。(我需要进行测试以确保,但我认为 DJ 无法处理这么多工作)

Resque and beanstalkd don't do the enqueue_in.

Resque 和 beanstalkd 不执行 enqueue_in。

There is a plugin (resque_scheduler) that does it, but I'm not sure of how stable it is.

有一个插件 (resque_scheduler) 可以做到这一点,但我不确定它有多稳定。

Our enviroment is on amazon, and they rolled out the beanstalkd for free for who has amazon instances, that is a plus for us, but I'm still not sure what is the best option here.

我们的环境在亚马逊上,他们为拥有亚马逊实例的人免费推出了 beanstalkd,这对我们来说是一个加分项,但我仍然不确定这里的最佳选择是什么。

We run rails 2.3 but we are bringing it to speed to rails 3.0.3 soon.

我们运行 rails 2.3,但我们很快就会将其加速到 rails 3.0.3。

But what is my best choice here? Am I missing another gem that does this job better?

但我在这里最好的选择是什么?我是否错过了另一个可以更好地完成这项工作的宝石?

I feel my only option that actually works now is the resque_scheduler.

我觉得我现在唯一真正有效的选择是 resque_scheduler。

Edit:

编辑:

Sidekiq (https://github.com/mperham/sidekiq) is another option that you should check it out.

Sidekiq ( https://github.com/mperham/sidekiq) 是您应该检查的另一个选项。

回答by andrea

For my projects I will feel very comfortbale with collectiveidea/delayed_jobin rails2 and 3. I don't know beanstalkd, but i will try it soon :-). I have followed the suggestions in the resque documentation. I will report it.

对于我的项目,我会对rails2 和 3 中的集体想法/延迟工作感到非常舒服。我不知道 beanstalkd,但我很快就会尝试:-)。我已遵循 resque 文档中的建议。我会报告的。

Resque vs DelayedJob

How does Resque compare to DelayedJob, and why would you choose one over the other?

Resque 与 DelayedJob 相比如何,为什么您会选择其中之一?

  • Resque supports multiple queues
  • DelayedJob supports finer grained priorities
  • Resque workers are resilient to memory leaks / bloat
  • DelayedJob workers are extremely simple and easy to modify
  • Resque requires Redis
  • DelayedJob requires ActiveRecord
  • Resque can only place JSONable Ruby objects on a queue as arguments
  • DelayedJob can place any Ruby object on its queue as arguments
  • Resque includes a Sinatra app for monitoring what's going on
  • DelayedJob can be queried from within your Rails app if you want to add an interface
  • Resque 支持多队列
  • DelayedJob 支持更细粒度的优先级
  • Resque 工作人员对内存泄漏/膨胀有弹性
  • DelayedJob 工人极其简单且易于修改
  • Resque 需要 Redis
  • DelayedJob 需要 ActiveRecord
  • Resque 只能将 JSONable Ruby 对象作为参数放置在队列中
  • DelayedJob 可以将任何 Ruby 对象作为参数放置在其队列中
  • Resque 包含一个 Sinatra 应用程序,用于监控正在发生的事情
  • 如果你想添加一个接口,可以从你的 Rails 应用程序中查询 DelayedJob

If you're doing Rails development, you already have a database and ActiveRecord. DelayedJob is super easy to setup and works great. GitHub used it for many months to process almost 200 million jobs.

如果您在进行 Rails 开发,那么您已经拥有一个数据库和 ActiveRecord。DelayedJob 非常容易设置并且效果很好。GitHub 使用它几个月来处理了近 2 亿个作业。

Choose Resque if:

在以下情况下选择 Resque:

  • You need multiple queues
  • You don't care / dislike numeric priorities
  • You don't need to persist every Ruby object ever
  • You have potentially huge queues
  • You want to see what's going on
  • You expect a lot of failure / chaos
  • You can setup Redis
  • You're not running short on RAM
  • 您需要多个队列
  • 你不在乎/不喜欢数字优先级
  • 你不需要持久化每个 Ruby 对象
  • 你有潜在的巨大队列
  • 你想看看发生了什么
  • 你期待很多失败/混乱
  • 你可以设置Redis
  • 您的 RAM 并不短缺

Choose DelayedJob if:

在以下情况下选择 DelayedJob:

  • You like numeric priorities
  • You're not doing a gigantic amount of jobs each day
  • Your queue stays small and nimble
  • There is not a lot failure / chaos
  • You want to easily throw anything on the queue
  • You don't want to setup Redis
  • 你喜欢数字优先级
  • 你不是每天都在做大量的工作
  • 您的队列保持小而灵活
  • 没有很多失败/混乱
  • 您想轻松地将任何东西扔到队列中
  • 你不想设置Redis

Choose Beanstalkd if:

在以下情况下选择 Beanstalkd:

  • You like numeric priorities
  • You want extremely fast queue
  • You don't want to waste you RAM
  • You want to serve high number of jobs
  • You're fine with JSONable Ruby objects on a queue as arguments
  • You need multiple queues
  • 你喜欢数字优先级
  • 你想要极快的队列
  • 你不想浪费你的内存
  • 您想为大量工作提供服务
  • 您可以将队列中的 JSONable Ruby 对象作为参数
  • 您需要多个队列

In no way is Resque a "better" DelayedJob, so make sure you pick the tool that's best for your app.

Resque 绝不是“更好”的 DelayedJob,因此请确保选择最适合您的应用程序的工具。

A nice comparison of queueing backend speed:

排队后端速度的一个很好的比较

                 enqueue                work
-------------------------------------------------
delayed job |   200 jobs/sec     120 jobs/sec
resque      |  3800 jobs/sec     300 jobs/sec
rabbitmq    |  2500 jobs/sec    1300 jobs/sec
beanstalk   |  9000 jobs/sec    5200 jobs/sec

Have a nice day!

祝你今天过得愉快!

P.S. There is a RailsCast about resque, Delayed Job(revised version) and Beanstakld. Have a look!

PS 有一个关于resqueDelayed Job修订版)和Beanstakld 的 RailsCast。看一看!

P.P.S. My favourite choiche is now Sidekiq( very Simple, Fast and efficient for simple jobs ), have a look at this pagefor comparison.

PPS 我最喜欢的 choiche 现在是Sidekiq(对于简单的工作非常简单、快速和高效),请查看此页面进行比较。

回答by Alister Bulman

Amazon Beanstalk isn't Beanstalkd.

Amazon Beanstalk 不是 Beanstalkd。

Beanstalkd - the queue - does have delayed jobs, that won't be reserved out of the queue until the given number of seconds have passed. If that is what Enqueue_in(10.hours, ... )means, then it's just syntactic sugar to calculate the number of seconds, and not make a job available till then.

Beanstalkd - 队列 - 确实有延迟的作业,在给定的秒数过去之前不会保留在队列之外。如果那是什么Enqueue_in(10.hours, ... )意思,那么它只是计算秒数的语法糖,直到那时才提供工作。

回答by altuure

Just a small note: delayed_job 3.0+supports named queues

只是一个小提示:delayed_job 3.0+支持命名队列

object.delay(:queue => 'tracking').method    
Delayed::Job.enqueue job, :queue => 'tracking'    
handle_asynchronously :tweet_later, :queue => 'tweets'