My app is built on Rails and my production server is on Heroku.
My application is mostly used for file upload and file processing and it takes more than 50 seconds for the request to process. As per the Heroku configuration my request does not respond in time and it sends me to the application error page due to request timeout.
How can I change the request timeout configuration on Heroku?
Please help me out to make application working.
The HyperText Transfer Protocol (HTTP) 408 Request Timeout response status code means that the server would like to shut down this unused connection. It is sent on an idle connection by some servers, even without any previous request by the client.
A restart cancels long-running requests. Restarting can resolve H12 issues because freshly-booted dynos receive requests without interference from long-running requests. Using the Heroku CLI, run heroku ps:restart web to restart all web dynos. or, using the Heroku Dashboard, click More, then Restart all dynos.
Request timeout is sent by a server indicating that the server wants to close the connection (note that sometimes server may close the connection without sending a message).
This is not possible according to Heroku's documentation
The timeout value is not configurable. If your server requires longer than 30 seconds to complete a given request, we recommend moving that work to a background task or worker to periodically ping your server to see if the processing request has been finished. This pattern frees your web processes up to do more work, and decreases overall application response times.
As already mentioned, you need to process it in the background because you cannot change the timeout enforced by Heroku. This is actually a good thing, because it will allow for a much better design where the web application is responsive and it can also scale much better.
What this means is that you need to use something like for instance delayed job and you can read about it on Heroku here.
The flow of things would be something like this:
This is an idea how this can be done. You have a few different ways you can do it and delayed job is just one you can choose from.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With