Heroku intermittent error H15 'Idle connection' on boot

I have a heroku app with Rails 4.1.5 on Ruby 2.1.1.

The app includes a bit of media processing and includes a javascript upload feature with Dropzone JS to an action that saves the photo to Amazon S3 until later processed in a background job.

I have a very annoying problem. Intermittently - and depending on the speed of the internet connection - Heroku router kills the download action with status H15 (idle connection). I do not believe that the connection was really idle, because using the same Internet connection I can upload similar files to other sites.

This is unrelated to the web dyno timeout as the request never hits the dyno in these cases where the router first disconnects it.

What could be here?

Note. I have implemented this CORS handling technique: http://www.tsheffler.com/blog/?p=428

Logs:

[Timestamp] heroku [router]: at = error code = H15 desc = "Idle connection" method = POST path = "/ console / breeds / 57-YAMTALE / photos" host = [host] request_id = 634d7680-8b66 -4123- a4bc-fe78dc4e7b90 fwd = "[IP]" dyno = web.1 connect = 0ms service = 90232ms status = 503 bytes = 0

Procfile:

web: bundle exec rails server thin -p \ $ PORT -e \ $ RACK_ENV

Gems that can make a difference:

gem 'thin'

gem 'carrierwave'

gem 'carrierwave_backgrounder'

gem 'rmagick' ,: require => 'RMagick'

gem 'aws-sdk'

gem 'rack-cors' ,: require => 'rack / cors'

gem 'daemons'

gem 'exception_notification'

+3


source to share


1 answer


You need to upload large files directly to S3 (or equivalent) and not through the Heroku app. You can place the urn in your application (probably using javascript) and then process from / to S3 in the background.

This is unfortunately related.

Heroku has (actually pretty good) instructions for one specific approach to this: https://devcenter.heroku.com/articles/direct-to-s3-image-uploads-in-rails

More details

The Heroku router will time out if it doesn't receive the first byte back within 30 seconds. After that, it will keep track of the 55 second rolling window, which is reset anytime a byte is transferred up or down. https://devcenter.heroku.com/articles/request-timeout

In your case, I am guessing that your download sometimes takes longer than 30 seconds. Although you are processing the file as a background task, I am assuming that you are not sending the first byte until the download is complete. Hence, intermittent timeout.

In the same Heroku doc ​​mentioned above:

Many web applications allow users to upload files. When these files are large, or the user is on a slow Internet connection, the download may take over 30 seconds. For this, we recommend directly uploading to S3.



Uploaded files

I believe there is an alternative way to solve this problem using HTTP uploaded downloads where the first byte response can be sent early. (This will only work on Cedar 1.1 and newer which supports 55 second rolling window)

In fact, the channelized approach should be simpler than the direct S3 method above. I've never considered this for several reasons:

1) Geroku doesn't mention this as an option.

2) This will go against general advice from Geroku:

The best practice is to keep your web application's response time under 500ms, this will free up the application for more requests and provide visitors with a high level of quality.

3) This could (based on my understanding, it would) adversely affect Heroku's load balancing, which is primitive (or broken depending on who you ask).

0


source







All Articles