开发者

Do Ruby Resque workers run in parallel?

开发者 https://www.devze.com 2023-03-30 23:58 出处:网络
I queued up a 开发者_JS百科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

I queued up a 开发者_JS百科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. Here is some example output of pulling down pages from an external http api:

Page: 124 Page: 125 Page: 126 Page: 127 Page: 128 Page: 129 Page: 130 Page: 131 Page: 132 Page: 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. If you only have one resque worker processing a given queue, that queue will be processed serially. If multiple resque workers process a single queue you should see the results come back out of order as you expected.

0

精彩评论

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