'How could I find what php is running when it slows down, like a sleep() command?

Is there any built in debugging options or some way to monitor what php is doing? I have a few scripts that take long to load. Like is there a way to find a random sleep() input buried in the code? One script I had, I found a loose sleep command, but I found that accidentally, was wondering if I could've found it without explicitly looking for it.

Thanks



Solution 1:[1]

You want to make use of slow PHP-FPM logging.

E.g. this PHP-FPM pool configuration will log PHP traceback for scripts running 3 or more seconds:

slowlog = /srv/www/example.com/logs/slow.log
request_slowlog_timeout = 3s

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Danila Vershinin