Note that there are some explanatory texts on larger screens.

plurals
  1. POBest practice for Rails App to run a long task in the background?
    text
    copied!<p>I have a Rails application that unfortunately after a request to a controller, has to do some crunching that takes awhile. What are the best practices in Rails for providing feedback or progress on a long running task or request? These controller methods usually last 60+ seconds. </p> <p>I'm not concerned with the client side... I was planning on having an Ajax request every second or so and displaying a progress indicator. I'm just not sure on the Rails best practice, do I create an additional controller? Is there something clever I can do? I want answers to focus on the server side using Rails only.</p> <p>Thanks in advance for your help.</p> <p>Edit:</p> <p>If it matters, the http request are for PDFs. I then have Rails in conjunction with Ruport generate these PDFs. The problem is, these PDFs are very large and contain a lot of data. Does it still make sense to use a background task? Let's assume an average PDF takes about one minute to two minutes, will this make my Rails application unresponsive to any other server request during this time?</p> <p>Edit 2:</p> <p>Ok, after further investigation, it seems my Rails application is indeed unresponsive to any other HTTP requests after a request comes in for a large PDF. <strong>So, I guess the question now becomes: What is the best threading/background mechanism to use?</strong> It must be stable and maintained. I'm very surprised Rails doesn't have something like this built in.</p> <p>Edit 3:</p> <p>I have read this page: <a href="http://wiki.rubyonrails.org/rails/pages/HowToRunBackgroundJobsInRails" rel="noreferrer">http://wiki.rubyonrails.org/rails/pages/HowToRunBackgroundJobsInRails</a>. I would love to read about various experiences with these tools.</p> <p>Edit 4:</p> <p>I'm using Passenger Phusion "modrails", if it matters.</p> <p>Edit 5:</p> <p>I'm using Windows Vista 64 bit for my development machine; however, my production machine is Ubuntu 8.04 LTS. Should I consider switching to Linux for my development machine? Will the solutions presented work on both?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload