# Backgroundrb issues

**URL:** <https://www.ruby-forum.com/t/backgroundrb-issues/134365>\
**Category:** Rails\
**Created:** [April 10, 2008, 6:28am UTC](https://www.ruby-forum.com/t/backgroundrb-issues/134365 "2008-04-10T06:28:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfaulkenberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c2a13f/32.png) [@jfaulkenberry](https://www.ruby-forum.com/u/jfaulkenberry)\
**Post date:** [April 10, 2008, 6:28am UTC](https://www.ruby-forum.com/t/backgroundrb-issues/134365/1 "2008-04-10T06:28:27Z")

</div>

Hi there,

I’m making a site that does a lot of image processing. In order to  
avoid timeouts while the clients image is being processed I have used  
backgroundrb to process the images.

However, I have a few small issues:

1. Images tend to come in short, intense bursts. I want all the  
images to be processed at the same time, but it seems like drb is  
processing the images in sequence, with each image waiting for the  
next to be processed before it starts processing. Is there any way to  
make drb process them all concurrently?

2. Sometimes my worker just doesn’t start. I can’t find any errors  
anywhere. But looking the log indicated that the worker never got the  
message to start. I can’t see any correlation between image size, type  
or anything. It seems pretty random but happens about once every 10  
images. If it was a problem with my code I would expect to see an  
error message somewhere, but I can’t find one. I am assuming that  
something goes wrong, or gets lost, and that the error is never  
logged.

Does anyone have any suggestions?

Thanks,  
Jonzo.

---

<div class="post-metadata">

**Author:** ![jfaulkenberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c2a13f/32.png) [@jfaulkenberry](https://www.ruby-forum.com/u/jfaulkenberry)\
**Post date:** [April 10, 2008, 4:09pm UTC](https://www.ruby-forum.com/t/backgroundrb-issues/134365/2 "2008-04-10T16:09:49Z")

</div>

Hi Jonzo,

I’m also using backgroundrb for images processing. Mine are processing  
the images one at a time - not really an issue for my application,  
after all the application has returned control to the user. I’m not  
getting any problems with ‘bursts’ of activity or missing workers btw  
I’m using the latest backgroundrb. Processing time seems very linear.  
Deployment OS is Centos, RMagick for processing and Mysql for DB  
( images stored in filesystem).

regards  
Kevin

---

<div class="post-metadata">

**Author:** ![jfaulkenberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c2a13f/32.png) [@jfaulkenberry](https://www.ruby-forum.com/u/jfaulkenberry)\
**Post date:** [April 11, 2008, 3:55am UTC](https://www.ruby-forum.com/t/backgroundrb-issues/134365/3 "2008-04-11T03:55:17Z")

</div>

Thanks Kevin, it’s good to know that it does work for some people!

The bursts of activity isn’t actually a bug or problem, it’s just the  
way my application behaves. Typically people will upload 10 or so  
images at once so I am starting that many workers. It just seems like  
sometimes the workers don’t start, and when one of the workers doesn’t  
start there is nothing printed out in any log files. no errors, and  
none of the log entries I have put in my code either.

Can you see any errors in my logic/code?

Here is my worker code:

============================================

class FileProcessorWorker \< BackgrounDRb::MetaWorker  
set\_worker\_name :file\_processor\_worker  
def create(args = nil)  
# this method is called, when worker is loaded for the first time  
end

def process( file\_id )  
begin  
logger.info “processing file now”  
file = UploadedFile.find( file\_id )  
logger.info “file: #{ file.inspect }”  
if file && file.original  
file.process  
logger.info “file processing completed”  
else  
logger.info “file not processed”  
end  
rescue  
logger.info “file processing error: #{ $! }”  
end  
end

end

============================================

And I am starting my worker like this (after my model is created):

def start\_worker  
MiddleMan.worker(:file\_processor\_worker).process(id)  
end

Thanks,  
Jonzo.
