processing loop

O

Omri Cohen

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
 
P

Pete Hodgson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,652
Latest member
Campbellamy

Latest Threads

Top