In PHP development work is very much used to timeout processing to the occasion, I say a few scenarios: get the data asynchronously if a backend data source gets unsuccessful, it skips and does not affect the entire page presentation in order to ensure that the Web server will not be able to access other pages because of poor performance on the page, Some of the page operation settings for some upload or uncertain processing time, you need to the entire process of the timeout set to infinity, or any one link set improperly, will cause inexplicable execution interrupt multiple back-end modules (MySQL, Memcached, HTTP interface), In order to prevent a single interface performance is too poor, causing the entire front to get data too slow, affecting the page opening speed, causing avalanches ... Lots of situations that need to be timed out
These places need to consider timeout settings, but the PHP timeout is categorized, the various processing methods and strategies are different, in order to describe the system, I summed up the common PHP in the time-out processing summary.
"Web Server timeout Processing"
[Apache]
Typically, in high performance situations, the default timeout configuration is 30 seconds, but when uploading files, or if the network is slow, the timeout operation may be triggered.
There are currently three timeout settings in APACHEFASTCGIPHP-FPM mode:
FastCGI Timeout setting:
Modify the httpd.conf fastcgi connection configuration, similar to the following:
The code is as follows
the maximum number of requests per keep-alive, and the default value is
server.max-keep-alive-requests=100 keep-alive Maximum wait time, in seconds, default value is 5
number of work server.max-keep-alive-idle=1200 lighttpd, default value is 0, single process runs
server.max-worker=2 limits the maximum intermediate pause time (in seconds) for a user to send a request, and if the user is in the process of sending a request (no request has been made), the middle pause is too long and LIGHTTPD will actively disconnect The default value is 60 (seconds)
server.max-read-idle=1200 limits the maximum intermediate pause time (in seconds) for a user to receive an answer, and if the user is in the process of receiving an answer (not finished), the middle pause is too long. LIGHTTPD will actively disconnect The default value is 360 (sec)
server.max-write-idle=12000 Read client request timeout limit, in seconds, with 0 for no limit set less than Max-read-idle, read-timeout effective
Server.read-timeout=0 Write Answer page to the client timeout limit, the unit is seconds, with 0 to indicate that no limit set is less than Max-write-idle, write-timeout effective
server.write-timeout=0 Request Processing time limit, if the mod_proxy_core, that is, and back-end interaction time limit, the unit is seconds
server.max-connection-idle=1200
Description
For a continuous request on a keep-alive connection, the maximum interval for sending the first request content is determined by the parameter max-read-idle, and from the second request the maximum interval for sending the requested content is determined by the parameter max-keep-alive-idle. The interval timeout between requests is also determined by Max-keep-alive-idle. The total time timeout for sending the requested content is determined by the parameter read-timeout. The timeout for lighttpd and back-end interaction data is determined by Max-connection-idle.
[Nginx]
Configuration: nginx.conf
The code is as follows:
http{
#Fastcgi:(Fastcgi for the backend, Fastcgi is not in proxy mode)
FASTCGI_CONNECT_TIMEOUT5; #连接超时
fastcgi_send_timeout10; #写超时
fastcgi_read_timeout10; #读取超时
#Proxy:(in effect for proxy/upstreams)
proxy_connect_timeout15s; #连接超时
proxy_read_timeout24s; #读超时
proxy_send_timeout10s; #写超时
}
Description
The timeout setting for Nginx is very clear and easy to understand, and the above timeout is for different working modes, but the problem with timeouts is very much.
Hope that the above is helpful to you, finally, please help to order a praise thank you ...