PHP - Increasing Request Timeout in FPM

By default, the PHP buildpack for Dokku configures a 30 second request timeout for FPM worker processes. To modify this value, you'll need to include a custom FPM config file in your application.

First create a file named fpm_custom.conf in the root of your git project. Inside that file, add this entry, modifying the duration time as needed:

request_terminate_timeout = 45s

Then modify your application's Procfile by adding -F fpm_custom.conf. Depending on your original Procfile configuration, the final result will look like one of the following examples:

web: vendor/bin/heroku-php-apache2 -F fpm_custom.conf

web: vendor/bin/heroku-php-apache2 -F fpm_custom.conf public/

web: vendor/bin/heroku-php-nginx -F fpm_custom.conf

web: vendor/bin/heroku-php-nginx -F fpm_custom.conf public/

Check in the above changes and push a new deployment.

Warning: increasing request_terminate_timeout can reduce the overall performance of your Web application as concurrent users increase if the average request time requires more than 30 seconds to process. Be careful with this setting! For time consuming tasks like report generation, it's better to generate the result asynchronously using a background process and poll for the result using a browser-side script, redirecting the user to the final output.