Autoscaling with periodic slow requests

33 views Asked by At

We're using the autoscaler on Heroku. Almost all the requests are very quick (0-500ms), but periodically we have an image upload that takes a long time (3000-9000ms). Autoscaling doesn't help at all in this case. Is there a best practice handle this? For instance, is there a way to omit a particular URL from the autoscaler? Or do you handle this by setting up a parallel app just to handle these transactions?

Here is an example "slow" transaction (with identifiers anonymized) -- all times are intact:

May 22 11:46:19 production heroku/router: at=info method=POST path="/api/users/cases/24070/case_posts.json" host=www.website.com request_id=XXX...XXX fwd="xxx.xxx.xxx.xxx" dyno=web.1 connect=0ms service=10483ms status=200 bytes=1762 protocol=https
Started POST "/api/users/cases/24070/case_posts.json" for xxx.xxx.xxx.xxx at 2018-05-22 18:46:10 +0000
Processing by Users::CasePostsController#create as JSON
  Parameters: {
    "image"=>#<ActionDispatch::Http::UploadedFile:0x00007f3068cb98d8 @tempfile=#<Tempfile:/tmp/RackMultipart20180522-11-1x9ayll.JPG>,
    @original_filename="IMG_1325.JPG",
    @content_type="image/jpeg",
    @headers="Content-Disposition: form-data; name=\"image\"; filename=\"IMG_1325.JPG\"\r\nContent-Type: image/jpeg\r\n">,
    "step"=>"pack out",
    ...
  }
  Rendered users/case_posts/_case_post.json.jbuilder (1.0ms)
  Rendering users/case_posts/show.json.jbuilder
  Rendered users/case_posts/_case_post.json.jbuilder (0.4ms)
  Rendered users/case_posts/show.json.jbuilder (1.0ms)
Completed 200 OK in 9120ms (Views: 1.8ms | ActiveRecord: 29.8ms)
0

There are 0 answers