You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
php-fpm: graceful restart without blocking/losing requests
## Issue:
When php-fpm gets "graceful" reloaded it will stop accepting requests
while finishing reqests it already received. If those requests to finish
are of a long running kind like big uploads over a slow connection, this
will block new requests to be handled for an unacceptable long time.
### Current behavior
```
|
v FPM (OLD) running
|
v $ sudo kill -USR2 $(cat /run/php-fpm/php-fpm.pid)
|
v OLD sends SIGQUIT to children
v OLD stops handling requests
|
v OLD keeps running until all children complete or time out
|
v OLD exec()s
v FPM (NEW) starts & re-uses listening socket
|
v NEW handles incoming requests from now on
```
## Proposed Solution:
In the case of a reloading request, we immediately fork and exec a new
fpm instance to seamlessly handle new requests, while the old instance
keeps finishing those requests already accepted.
### New behavior
```
|
v FPM (OLD) running
|
v $ sudo kill -USR2 $(cat /run/php-fpm/php-fpm.pid)
|
v OLD sends SIGQUIT to children
v OLD fork()s & exec()s
|\
| \
| v FPM (NEW) starts & re-uses listening socket
| v NEW handles incoming requests from now on
| |
v | OLD keeps running until all children complete or time out
v | OLD gone
- |
/
/
v NEW still going
|
```
We've been running this patch since PHP 5.6 (early 2017).
0 commit comments