Dockerized deployment request timeouts
Unanswered
Orange-tailed bumble bee posted this in #help-forum
Orange-tailed bumble beeOP
Hi,
When deploying nextjs with Docker, what are the default timeouts on API routes? Also, how can i change that?
Does the maxDuration setting also apply to the docker deployment?
When deploying nextjs with Docker, what are the default timeouts on API routes? Also, how can i change that?
Does the maxDuration setting also apply to the docker deployment?
14 Replies
it existed in the first place because routes in nextjs are meant to be run on a serverless function at vercel
since you're self-hosting a next server on your own by dockerizing it, the limit became kinda useless
as for the question whether it affects self-hosted apps, im not quite sure, you could try it out by setting an absurdly small
maxDuration and see if it throws a timeout when running it by selfhostyup as mentioned at the docs here, nextjs by default does not restrict the execution time; but deployers like vercel could use it to add specific execution limits of the function https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#maxduration
Orange-tailed bumble beeOP
Understood, thanks! Is there any way that I can easily configure timeouts on the docker container?
i'd recommend setting up something like nginx over it then configure timeouts there
im afraid js won't be that good at handling those types of things
Orange-tailed bumble beeOP
Ok, i have nginx in place. I will handle everything there.
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout this seems be what you'd need
good luck
Orange-tailed bumble beeOP
Thx! If setting proxy_read_timeout, how would you relate this to keepAliveTimeout?
https://nextjs.org/docs/app/api-reference/cli/next#configuring-a-timeout-for-downstream-proxies
"it's important to configure Next's underlying HTTP server with keep-alive timeouts that are larger than the downstream proxy's timeouts."
So if i set proxy_read_timeout to 100 seconds, i should set this to something like 110?
https://nextjs.org/docs/app/api-reference/cli/next#configuring-a-timeout-for-downstream-proxies
"it's important to configure Next's underlying HTTP server with keep-alive timeouts that are larger than the downstream proxy's timeouts."
So if i set proxy_read_timeout to 100 seconds, i should set this to something like 110?
oh cool, i had never heard of that
but wouldn't that make everything to be under that timeout? in case you'd only need a single route to have a timeout, i don't think that would work well