When I send a request to newly created rails application (with rails new ) it works fast:

~ 冬 time curl -v -X POST --data key=value http://localhost:3000/ok Note: Unnecessary use of -X or --request, POST is already inferred. * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 3000 (#0) > POST /ok HTTP/1.1 > Host: localhost:3000 > User-Agent: curl/7.51.0 > Accept: */* > Content-Length: 9 > Content-Type: application/x-www-form-urlencoded > * upload completely sent off: 9 out of 9 bytes < HTTP/1.1 200 OK < X-Frame-Options: SAMEORIGIN < X-XSS-Protection: 1; mode=block < X-Content-Type-Options: nosniff < Content-Type: application/json; charset=utf-8 < ETag: W/"a29ee2b15c494311c52521766e44af56" < Cache-Control: max-age=0, private, must-revalidate < X-Request-Id: 99e6d922-dcd6-4e25-89a2-35fa735a401e < X-Runtime: 0.003076 < Transfer-Encoding: chunked < * Curl_http_done: called premature == 0 * Connection #0 to host localhost left intact {"status":"ok"}curl -v -X POST --data key=value http://localhost:3000/ok 0.00s user 0.00s system 23% cpu 0.014 total

However, if I send a file or multipart/form-data it always take 1 second extra ( 1.014 total ):

~ 冬 time curl -v -X POST --form key=value http://localhost:3000/ok Note: Unnecessary use of -X or --request, POST is already inferred. * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 3000 (#0) > POST /ok HTTP/1.1 > Host: localhost:3000 > User-Agent: curl/7.51.0 > Accept: */* > Content-Length: 143 > Expect: 100-continue > Content-Type: multipart/form-data; boundary=------------------------8cda3c76e0dbb84a > * Done waiting for 100-continue < HTTP/1.1 100 Continue < HTTP/1.1 200 OK < X-Frame-Options: SAMEORIGIN < X-XSS-Protection: 1; mode=block < X-Content-Type-Options: nosniff < Content-Type: application/json; charset=utf-8 < ETag: W/"a29ee2b15c494311c52521766e44af56" < Cache-Control: max-age=0, private, must-revalidate < X-Request-Id: 13720420-bd08-44f8-8a98-aca57d70331a < X-Runtime: 0.002236 < Transfer-Encoding: chunked < * Curl_http_done: called premature == 0 * Connection #0 to host localhost left intact {"status":"ok"}curl -v -X POST --form key=value http://localhost:3000/ok 0.01s user 0.00s system 0% cpu 1.014 total

application_controller.rb:

class ApplicationController < ActionController::Base # protect_from_forgery with: :exception def ok render json: {status: 'ok'} end end

routes.rb:

Rails.application.routes.draw do post '/ok' => 'application#ok' end

I tested this on several different linux machines and also, similar php code works without such delay.

Also, I tried to debug the puma server and found out that it freeze here:

# reactor.rb, line 29 while true begin ready = IO.select sockets, nil, nil, @sleep_for # waits one second here < ... >

The sockets argument contains Puma::Client instance and I don't have a clue how an object of this class can be passed to IO.select .

Any ideas on how to eliminate one second waiting?