Unicorn timeout error while downloading file

I use a unicorn on Hereka. one of the problems I encountered is related to uploading files. We use the carrier to load, and basically even for a file of about 2 MB in size, by the time of loading 50-60% Unicorn is disconnected.

We do not use a unicorn for local testing, and I have no problem with large files locally (although the files are uploaded to AWS using a carrier, as in setting + setting). However, on intermediate and production servers, I see that we are getting a timeout.

Any strategies to fix this problem? I am not sure that I can upload this file in slow motion (because I need to confirm to my users that the file really downloaded successfully).

Thanks! Ringo

+6
source share
2 answers

If you upload large files to S3 via Heroku, you cannot reasonably avoid timeouts. If someone decides to upload a large file, he will go into timeout. If it takes more than 30 seconds to download to Heroku, go to S3 and process the request, the timeout will expire. For a good reason, a 30s request is just crappy performance.

This blog post (and github repo) is very useful: http://pjambet.imtqy.com/blog/direct-upload-to-s3/

With it, you can work with files with direct access to s3. You completely avoid getting Heroku to the main part of the download. Using jquery-fileupload callbacks, you can send a message to the application after the file has been successfully downloaded and process it in the background using delayed_job. Confirming users a successful download is an application issue that you just need to take care of.

+2
source

It looks like your timeout is set too low. What does your unicorn configuration look like?

See https://devcenter.heroku.com/articles/rails-unicorn for a good starting point.

0
source

Source: https://habr.com/ru/post/954710/


All Articles