简体   繁体   English

Ruby Resque工作者并行运行吗?

[英]Do Ruby Resque workers run in parallel?

I queued up a bunch of jobs given each one an id that gets printed out. 我排队了一堆工作,每个工作都会被打印出来。 What I find surprising is when I queue up 140 jobs each with varying sleep(n) in them I still see the output of the workers in sequential order. 令我惊讶的是,当我排队140个工作,每个工作有不同的睡眠(n),我仍然按顺序看到工人的输出。 Here is some example output of pulling down pages from an external http api: 以下是从外部http api下拉页面的一些示例输出:

Page: 124 Page: 125 Page: 126 Page: 127 Page: 128 Page: 129 Page: 130 Page: 131 Page: 132 Page: 133 页次:124页数:125页数:126页次:127页次:128页次:129页次:130页次:131页次:132页次:133

Shouldn't this come back out of order since each page could take different amount of time? 由于每个页面可能需要不同的时间,因此不应该出现故障吗?

Each resque worker runs in a single thread. 每个resque工作程序都在一个线程中运行。 If you only have one resque worker processing a given queue, that queue will be processed serially. 如果只有一个resque worker处理给定队列,则将对该队列进行串行处理。 If multiple resque workers process a single queue you should see the results come back out of order as you expected. 如果多个resque工作者处理单个队列,您应该看到结果按预期不按顺序返回。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM