A
A
Alexey Lushnikov2016-12-19 17:37:20
Ruby on Rails
Alexey Lushnikov, 2016-12-19 17:37:20

Why is uploading files in rails + puma so slow?

Hey!
Very strange rail behavior:
There is an empty action:

def show
    render json: {success: true}
  end

If you run a query like:
curl -X POST -H "Cache-Control: no-cache"  http://localhost

the result is 0.02 sec, which is good.
But if you send a file with a size of, for example, 1 mb per action, the result is very different:
curl -X POST -H "Cache-Control: no-cache"  -H "Content-Type: image/jpeg" -F "[email protected]" "http://locahost

result - 1.2 sec! it's no good.
those. if we add any data to the request body, the response time increases sooo much.
Theoretically, everything works locally, on ssd, the file delivery time to the application should be ~ 0 sec.
For comparison, I tested it on yii - the result is expected, 1 MB file is loaded into an empty action in 0.1 seconds.
Guys, gurus, what's the matter? What do rails do when parsing a request, which leads to brakes?
Same problem, just asked a question at stackoverflow.com/questions/41236396/1-second-late...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question