Rails,Heroku,Unicorn& Resque

编程入门 行业动态 更新时间:2024-10-26 20:25:24
本文介绍了Rails,Heroku,Unicorn& Resque - 如何选择网络工作者/ resque工作者的数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我刚刚转向在Heroku上使用独角兽。我也将切换到delayed_job的resque,并使用 bugsplat.info/2011-11-27-concurrency-on-heroku-cedar.html

我不明白从这是如何config / unicorn.rb:

worker_processes 3 超时30 @resque_pid = nil before_fork | server,worker | @resque_pid || = spawn(bundle exec rake+ \ resque:work QUEUES = scrape,geocode,distance,mailer) end $ b 实际上在每个网络测试中会产生六个过程:1个独角兽主人,3个独角兽网络工作者,1个重新工作者,1个重新启动的童工,当它实际上正在处理一项工作时

有多少员工会实际处理后台工作? 1或2?

可以说我想增加resque workers的数量 - 我会改变什么?

解决方案

我想如果你运行这个块,你的麒麟master已经在运行,再加上你在文件顶部指定的3个web worker,然后下面的块会启动一个Resque worker如果它还没有开始。

我猜Resque在实际执行工作时会自行启动一个子工作者。

$ b $如果你想要另一个Resque worker,你可以这样做:

worker_processes 3 timeout 30 @resque_pid = nil @ resque_pid2 = nil before_fork do | server,worker | @resque_pid || = spawn(bundle exec rake+ \ resque:work QUEUES = scrape,geocode,distance,mailer) @ resque_pid2 || = spawn( bundle exec rake+ \ resque:work QUEUES = scrape,geocode,distance,mailer) end

根据我对Resque的经验,就像启动上面指定的另一个过程一样简单。我所遇到的唯一不确定因素是Heroku以及它如何选择处理给你更多的工人。

I've just switched to using Unicorn on Heroku. I'm also going to switch to resque from delayed_job and use the setup described at bugsplat.info/2011-11-27-concurrency-on-heroku-cedar.html

What I don't understand from this is how config/unicorn.rb:

worker_processes 3 timeout 30 @resque_pid = nil before_fork do |server, worker| @resque_pid ||= spawn("bundle exec rake " + \ "resque:work QUEUES=scrape,geocode,distance,mailer") end

translates into:

"This will actually result in six processes in each web dyno: 1 unicorn master, 3 unicorn web workers, 1 resque worker, 1 resque child worker when it actually is processing a job"

How many workers will actually process background jobs? 1 or 2?

Lets say I wanted to increase the number of resque workers - what would I change?

解决方案

I think if you run that block, you have your unicorn master already running, plus 3 web workers that you specify at the top of the file, and then the block below launches one Resque worker if it's not already started.

I'm guessing that Resque launches a child worker by itself when it actually performs work.

It would appear that if you wanted another Resque worker, you could just do

worker_processes 3 timeout 30 @resque_pid = nil @resque_pid2 = nil before_fork do |server, worker| @resque_pid ||= spawn("bundle exec rake " + \ "resque:work QUEUES=scrape,geocode,distance,mailer") @resque_pid2 ||= spawn("bundle exec rake " + \ "resque:work QUEUES=scrape,geocode,distance,mailer") end

In my experience with Resque, it's as simple as launching another process as specified above. The only uncertainty I have is with Heroku and how it chooses to deal with giving you more workers.

更多推荐

Rails,Heroku,Unicorn& Resque

本文发布于:2023-10-16 05:17:31,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Heroku   Rails   Unicorn   Resque   amp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!