How to change default query request time on Heroku?

My application is built on Rails, and my production server is on Heroku.

My application is mainly used to upload files and process files, and it takes more than 50 seconds to process a request. According to Heroku configuration, my request does not respond on time, and it sends me to the page with the application error due to the request timeout.

How to change request timeout configuration on Heroku?

Please help me to make the application work.

+8
ruby-on-rails ruby-on-rails-3 heroku
source share
3 answers

This is not possible according to Heroku documentation

The timeout value is not configurable. If your server takes longer than 30 seconds to complete this request, we recommend that you work with a background job or worker to periodically ping your server to check if the processing request has completed. This model frees up your web work process to do more work, and reduces the overall application response time.

+14
source share

You must upload your large files directly to Amazon S3 or similar, and then process the file using the Heroku desktop. Typically, your webpage will use some kind of poll (usually an AJAX request) to see when processing has completed and refresh the interface.

0
source share

As already mentioned, you need to process it in the background because you cannot change the timeout set by Heroku. This is actually good, because it will significantly improve the design when the web application is responsive, and it can also scale significantly.

This means that you need to use something like a deferred task , and you can read about it on Heroku here .

The flow of things will be something like this:

  • upload a document within the hard limit (timeout) put in place by Heroku.
  • Schedule a background job to process the document and return 200 to the browser.
  • the browser is waiting for completion, for example. AJAX background polling the flag to see when the background work is ready.
  • deferred work picks up the scheduled work, and upon completion sets a flag to indicate the background job.
  • The browser can now inform the user that this is done (before your application, to find out what is suitable).

This is an idea how to do this. You have several different ways you can do this, and deferred work is just the one you can choose from.

0
source share

All Articles