php-fpm How to set timeout: 1. Set the content "request_terminate_timeout = 30"; 2. Set the content "max_execution_time = 30".
The operating environment of this article: nginx1.0.4 system, PHP7.1 version, DELL G3 computer
php-fpm nginx timeout parameter setting
php-fpm: request_terminate_timeout = 30 php.ini: max_execution_time = 30
request_terminate_timeout is suitable for when max_execution_time cannot terminate the script for some reason, this php-fpm request will be killed.
The execution time of web request PHP is controlled by two aspects, one is max_execution_time of php.ini (it should be noted that sleep, the time for http request to wait for response is not counted, here is the real execution time) , the other is the php-fpm request_terminate_timeout setting, which counts n seconds since the request started.
When this time is exceeded, PHP-FPM will not only terminate the execution of the script,
will also terminate the Worker process that executes the script. Therefore, Nginx will find that the connection to communicate with itself is broken, and will return a 502 error to the client.
The key parameters of nginx are fastcgi related timeout, namely: fastcgi_connect_timeout, fastcgi_read_timeout, fastcgi_send_timeout.
The subjects of these nginx parameters are all nginx, so fastcgi_connect_timeout means the timeout time for nginx to connect to fastcgi, fastcgi_read_timeout is the timeout time for nginx to read the content of fastcgi, and fastcgi_send_timeout is the timeout for nginx to send content to fastcgi. overtime time.
Nginx 504 Gateway Time-out means that no executable PHP-CGI was requested.
Nginx 502 Bad Gateway means that the requested PHP-CGI has been executed, but the PHP-CGI process was terminated because the resource reading was not completed.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to set timeout in php-fpm. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
