Siddharth Ram
Siddharth Ram

Reputation: 576

Timeouts with Heroku rails app with storage on S3

I have an app using rails 3.2, running on heroku and storing on S3. Users have the option of uploading photographs, which are processed using carrierwave/MiniMagick to various sizes.

The problem we are seeing is that 30% of the time, the browser times out. The upload code (there are upto four images that can be uploaded) looks like this: I am using carrierwave_backgrounder to delay image manipulation, but we still have timeouts. This is with fairly small images - typically, 150KB PNG's.

mount_uploader :image1, ImageUploader
process_in_background :image1

mount_uploader :image2, ImageUploader
process_in_background :image2

mount_uploader :image3, ImageUploader
process_in_background :image3

mount_uploader :image4, ImageUploader
process_in_background :image4

This is the error we see

app[web.1]: Started POST "/offices" for 197.16.140.27 at 2013-05-23 23:32:18 +0000
app[web.1]: E, [2013-05-23T23:32:49.042937 #2] ERROR -- : worker=0 PID:10 timeout (31s > 30s), killing

The same thing happens with both thin and Unicorn.

The reading I have done suggests that I should be uploading directly to S3, but then the image manipulation gets delayed which is a problem for me (latency/complexity) . What should I be doing different?

Upvotes: 4

Views: 2062

Answers (2)

Taavo
Taavo

Reputation: 2414

John is correct: This is what happens when you upload directly to heroku. I wrote about some strategies for handing heroku uploads here.

Upvotes: 2

John Beynon
John Beynon

Reputation: 37507

This is a common problem with uploads and something that can only be solved by uploading directly to S3 and performing the processing once completed. The problem you have is the user connection speed, if coming from a cell phone it's going to take a lot long that 30s compared to the same file being uploaded from someone on fast internet. You're not doing anything wrong at all, different servers won't make a difference either I'm afraid.

Upvotes: 1

Related Questions