0

after posting a question related to nginx, I'm a bit further with my investigations: The problem is, that the merb framework timeouts after about 30 seconds. If i tell the underlying nginx-server not to timeout, merb does, and I can't find a way to tell it not to; I need to do requests that take up to some minutes.

Any hints? Thanks a lot.

-- UPDATE --

Seems that mongrel behind merb is causing the error. Is there any way to change the mongrel-timeout running with merb?

schneck
  • 10,556
  • 11
  • 49
  • 74

1 Answers1

1

Perhaps a different approach would yield better results - rather than workaround the timeouts, how about maximizing throughput by deferring the execution of the task?

Some approaches for long-running tasks are to either use run_later or exec a separate worker process to complete the task ...

def run_in_background(r)
    Thread.new do
        response = IO.popen(r) do |f|
            f.read
        end
    end
end

In both cases you should return 202 (Accepted) as the status code and a URL where the calling application can get status updates.

I use this approach to handle requests which cause background batch processes to execute. Each writes it's start-time, progress and completion-time to a database (you could easily use a file). When the URL is invoked, I fetch the progress from the database and provide that back to the calling process.

Chris McCauley
  • 25,824
  • 8
  • 48
  • 65