Home > System Tutorial > LINUX > body text

Record once and use strace to diagnose the problem of PHP occupying too much system resources.

WBOY
Release: 2024-05-03 16:31:14
forward
878 people have browsed it

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:

  • Find a php child process id
  • strace -cp pid traces process calls

System load at that time:

Record once and use strace to diagnose the problem of PHP occupying too much system resources.

strace debugging process

Record once and use strace to diagnose the problem of PHP occupying too much system resources.

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
Copy after login

Record once and use strace to diagnose the problem of PHP occupying too much system resources.

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!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!