Processing loop

Hey guys,

I am trying to write an application with some various infinite loops
that basically poll data in a queue. Essentially, it is an asynchronous
webseerver, where requests come in, queue up the request and immediately
send a success response to the user. I am planning on having a separate
process polling this queue and handling the requests.

what i had in mind was something like:
while(1) do
queue.first.handle()
sleep(1)
end

I know Mongrel is single threaded so I was planning on using a
multithreaded server like Thin or LiteSpeed.

Any thoughts?

Thanks!

-Omri

Hi Omri,

Another option (which I’ve had some success with) is using BackgrounDRb
to manage a separate worker process which consumes items from a work
queue. This worker process can be multithreaded. Your web app processes
(mongrels or otherwise) would add work jobs to the queue using
BackgrounDRb’s IPC mechanisms. The work queue could be a database table,
or maintained in memory by the worker process.

Cheers,
Pete