Snippet · Building with models
Model calls that take longer than my host allows
When the answer takes three minutes and the host allows thirty seconds.
My app (<stack> on <host>) calls <model> for <task>. Some calls take minutes, and the host cuts requests off long before that. Design around the limit: - Start the job and return straight away with an ID. - Run the model call somewhere that's allowed to take its time on this host: a scheduled job, a background process, or the provider's own batch API. - Let the page check progress and show the result when it's ready. - Handle the call failing after the user has gone. Recommend one approach for this host.
If nobody is waiting on the result, the provider's batch API is often both the simplest route and half the price.