debugging long running PHP script

后端 未结 11 2541
我寻月下人不归
我寻月下人不归 2021-02-19 06:46

I have php script running as a cron job, extensively using third party code. Script itself has a few thousands LOC. Basically it\'s the data import / treatment script. (JSON to

11条回答
  •  暖寄归人
    2021-02-19 07:10

    Use strace to see what the program is basically doing from the system perspective. Is it hanging in IO operations etc.? strace should be the first thing you try when encountering performance problems with whatever kind of Linux application. Nobody can hide from it! ;)

    If you should find out that the program hangs in network related calls like connect, readfrom and friends, meaning the network communication does hang at some point while connecting or waiting for responses than you can use tcpdump to analyze this.

    Using the above methods you should be able to find out most common performance problems. Note that you can even attach to a running task with strace using -p PID.


    If the above methods doesn't help, I would profile the script using xdebug. You can analyse the profiler output using tools like KCachegrind

提交回复
热议问题