Unlike Unicorn, Puma doesn't have a builtin HTTP request timeout mechanism, so we have to use Rack::Timeout instead. See the caveats in the Rack::Timeout documentation [1]. In Unicorn, a timeout would send a SIGKILL to the worker, immediately killing it. This would result in a dropped connection and a Cloudflare 502 error to the user. In Puma, it raises an exception, which we can catch and return a better error to the user. On the other hand, raising an exception can potentially corrupt application state if it's sent at the wrong time, or be delayed indefinitely if the app is stuck in IO or C extension code. The default request timeout is 65 seconds. 65 seconds is to give things like HTTP requests on a 60 second timeout enough time to complete. Set the RACK_REQUEST_TIMEOUT environment variable to change the timeout. 1: https://github.com/sharpstone/rack-timeout#further-documentation
14 KiB
14 KiB