I want requests to timeout after some time, say 20 seconds. If the application takes longer than 20 seconds to send a response, Phoenix should cancel execution and immediately reply with some error (preferably an HTTP 503).
I've scoured the Phoenix docs but couldn't find any mention of a request timeout option. It looks like Cowboy has a :timeout
option, which I tried setting to 10 ms, but it still allowed a request to take 8951 ms:
config :app, SomeApp.Endpoint,
http: [port: 4000, timeout: 10]
It turns out the Cowboy docs define this option as:
Time in ms with no requests before Cowboy closes the connection.
which is not what I'm looking for.
Is it possible to set a request timeout in Phoenix?