1
votes

I'm running a rails 3.2.11 app on Heroku and running into an intermittent issue I have been unable to figure out.

I have a model that includes a file uploaded by a user. The file is typically about 300-400Kb. I am seeing an issue in production when a user attempts to create or edit this model and upload the file I am periodically getting an h12 timeout error. It's difficult to recreate the error as when I test it works fine pretty much all of the time, including up to 10mb, so the issue doesn't seem to hinge directly on file size.

I am using the carrierwave_direct gem to upload directly to S3. I started w/ the carrierwave gem and switched to carrierwave_direct in hopes it would solve the problem. I am not doing any post-processing of the file, I just need to get it uploaded.

I have re-created this error in prod with no users on the server other than myself so it doesn't seem to be a traffic problem either.

Example heroku log entry:

at=error code=H12 desc="Request timeout" method=POST dyno=web.1 queue=0ms wait=0ms connect=1ms service=33605ms status=503 bytes=0

Thanks!

1
did u tried one like explained in railscast?chaitanya

1 Answers

1
votes

Heroku times out requests that take longer that 30seconds - which is always a problem with uploads.

Using Amazon S3 you can direct upload without going through Heroku and have it pass a response to Heroku once the upload has completed thereby entirely bypassing Heroku's timeout - you would need to look to see if Rackspace offer such functionality.

http://railscasts.com/episodes/383-uploading-to-amazon-s3

Above link will help you out to upload image on s3 with help of carrierwave_direct and background jobs