开发者

Is there an easy way to handle BJ concurency

开发者 https://www.devze.com 2023-02-09 09:57 出处:网络
Is there a way to set jobs in BJ and make sur开发者_如何学JAVAe that 2 of a certain \"type\" are not running concurrently?

Is there a way to set jobs in BJ and make sur开发者_如何学JAVAe that 2 of a certain "type" are not running concurrently?

We are running 24 unicorns and it will allow a BJ to startup for each one of those. This is not a big deal b/c we like multiple job handlers knocking out background task. The exception is a data import. We want to be able to tell it not to run more than one of those at a time.

Is this possible in BJ or should we just move over to something like resque?


One way to do this would be to constrain your data import jobs to a certain priority level, and then make sure that only a single delayed job is picking up jobs of that priority. For example, if you wanted to let all your other jobs run from priority 0 to 99, and have your data import jobs run at priority 100, then you could have all your delayed job workers run from a min_priority of 0 to a max_priority of 99 and then you could have one delayed job worker running from min_priority 100 to max_priority 100, ensuring that only a single worker was running those jobs. This would ensure that no two import data jobs (priority 100) were running at the same time.

0

精彩评论

暂无评论...
验证码 换一张
取 消