Home > Article > System Tutorial > Record once and use strace to diagnose the problem of PHP occupying too much system resources.
Local environment: redhat6.7 system. nginx1.12.1, php7.1.0, the code uses the yii2 framework
Question: The local web site needs to use the elasticsearch service. When PHP uses elasticsearch built on a local server, the local load is normal. When I use AWS's elasticsearch service, the load on the local server is often too high. Check the nginx and php logs and find no exceptions. The number of concurrent connections in the system is also not high. At this time, I thought of a strace diagnostic tool that our boss told me.
Debugging process:
System load at that time:
strace debugging process
Here we find that when php calls elasticsearch, it will look for a file locally, and this file does not exist. This results in high server load. By comparing the difference between aws elasticsearch and local es cluster. I found that only the calling method was different. The code is called using the https method, so it will look for the certificate library file locally. I immediately contacted the development team and changed the calling method to http. After observing for a period of time, the server load returned to normal.
strace -T -e access -p 1379
The above is the detailed content of Record once and use strace to diagnose the problem of PHP occupying too much system resources.. For more information, please follow other related articles on the PHP Chinese website!