The solution to the php server http status code is 499

Reason: Some http requests are processed too slowly by the server, which affects other http requests.

1. Configure `max_execution_time` and `max_input_time` of php.ini. But after the change, I still reported a lot of 499.

(The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. The maximum time for any script execution that occurs such as system calls using system(), stream operations, database operations, etc. does not include it, when the script has been run .This is not the case in Windows where measured times are real-valued.)

2. Set it to `request_terminate_timeout = 10` in `php-fpm.conf`, 499 is rarely reported, but occasionally it will appear. `request_terminate_timeout` will kill the process, resulting in occasional 502 http status codes.

3. The `root cause` is that the processes provided by PHP are too few to handle, and more processes should be added.

The original configuration was:

pm.max_children = 5

pm.start_servers = 2

pm.min_spare_servers = 1

pm.max_spare_servers = 3

Change to: (can be adjusted larger according to the situation)

pm.max_children = 20

pm.start_servers = 10

pm.min_spare_servers = 10

pm.max_spare_servers = 20

4. Combine with php slow log (slowlog) to find out the scripts that execute slowly and optimize them.

set up:

request_slowlog_timeout = 5

slowlog = /data/logs/php-fpm-slowlog.log

Guess you like

Origin blog.csdn.net/tiging/article/details/132003352