FastCGI will launch the master process and as many forks of this master process as you have defined, and yes, these branched processes can work for a long time. This means that the process does not have to run the full PHP process every time it needs to execute a script. But that's not how you think your scripts are now working all the time. The start and stop phase is still executed every time a script is to be executed. At the moment, things like global variables (e.g. $_POST and $_GET ) are populating, etc. You can execute functions every time your process terminates with register_shutdown_function() .
If you do not use persistent connections to the database and do not close connections to the database, nothing bad will happen. As Colin Sean explained, PHP eventually closes them during shutdown.
However, I highly recommend that you close your connections, because a properly created program knows when the object's lifetime has expired and is cleared. This can give you exactly the milliseconds or nanoseconds that you need to deliver on time.
It's easy to always create standalone objects that are also cleaned up after they are finished with what they have done.
source share