Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku timeout when uploading big file to s3

I got a problem with my application based on RefineryCMS 1.0.8 deployed on heroku.

Heroku have a request timeout of 30 seconds. When uploading a file > 4MO through the RefineryCMS admin, it will sometimes take more than 30 seconds to perform the request (mostly because of the time needed to upload the file to s3).

In this case, the dyno will be "frozen" and unresponsive for around 30 minutes (every request during this time end up by a H12 Error request timeout). This behaviour is exactly what describe christos in the last message in this discussion

From this other discussion and the heroku documentation : "Direct Upload to S3 is the preferred approach if you’re working with file uploads bigger than 4MB. The idea is to skip the hop to your dyno, making a connection from the end user browser directly to S3."

The direct upload to S3 should be the solution but it looks difficult for me to implement it properly with RefineryCMS / Dragonfly / Fog. I'm not sure if it's possible without big modification in theses tools and I'm wondering if there is an alternative.

Thanks for your help

like image 831
Adrien Coquio Avatar asked Oct 21 '11 19:10

Adrien Coquio


People also ask

How do I upload a large file to Heroku?

Here's a high-level overview of my approach: Use the s3_swf_upload gem to supply a direct upload form to s3. Detect when the file is done uploading with the javascript callback function provided in the gem. Using javascript, send rails a post message to let your server know the file is done uploading.

How do I fix Heroku H12 error?

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.


1 Answers

Not really. The Heroku timeout is a set in stone thing that you need to work around. Direct upload to S3 is the only option, with some sort of post-upload processing required.

There are solutions out there such as CarrierWaveDirect, but I don't know how easy this would be to use with Refinery.

like image 52
Neil Middleton Avatar answered Oct 20 '22 00:10

Neil Middleton