I use backgroundrb for many long tasks in my system, but I''m having
issues
with one in particular. Two large tasks for me are importing people and
updating companies.
def import_contacts(args = nil)
thread_pool.defer(args) do |job_id|
begin
job = ImportJob.find(job_id)
job.process_job
rescue => err
logger.error "MscWorker#import_contacts failed! #{err.class}:
#{err}"
end
end
end
def update_company_from_vendor(args = nil)
thread_pool.defer(args) do |company_id|
begin
company = Company.find(company_id)
info = company.firm_info_from_vendor # webservice call to vendor
if info && info.size == 1
company.update_from_vendor!(
Company.find_firm_info_details_from_vendor(info[0])) # webservice call to
vendor
end
rescue => err
logger.error "MscWorker#update_company_from_vendor failed! #{
err.class}: #{err}"
end
end
end
Part of import_contacts will result in many ask_work calls to
update_company_from_vendor while it is processing. Importing contacts is
heavily db dependent, but not very code intensive. If I upload two files
with > 1000 contacts each (two ask_work calls to import_contacts), things
will progress along and then pause for 20-40 seconds. There is no DB
activity during the pause, but the backgroundrb process is using most of CPU
(98-99%). There are no deadlock errors when things startup again, but it
really slows things down. Are you using polling somewhere?
Also, on my Mac, Activity Monitor is only showing 1 thread and 1.2 Gig(!!)
of memory used. I expected to see many threads due to my use of
thread_pool.
Thoughts?
--
Dave Dupre
(m) 617-921-1684
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20080103/ca4cb781/attachment.html