Now there is a project on hand that runs a website in an embedded device with a Linux system.
The CPU of the device is RAM structure, single core, 1GB.
We set up a apache+mysql+php in the system and then write a website that runs inside. It feels a bit like the setup of the Web page inside the router, but it's a complete website app.
PHP runs very slowly on the device, but by merging PHP files (reducing IO), using APC (cache opcode and some data and pages), the speed of access is improved.
However, every time you visit the site inside the device, the CPU of PHP-FPM can take up to about 40%, and the CPU consumption will drop when the page is not accessed. Because other services and programs are running on the device, when PHP-FPM consumes too much CPU, it can cause other programs to become problematic.
Why does PHP-FPM occupy so many CPUs? Apache has not accounted for much, there is no way to let the CPU down.
Would have wanted to use some embedded Web server, but feel CPU usage is not the problem of Apache, is the problem of PHP, do not know how to handle. Do you have any suggestions or ideas?
PS: The site in the device has only one user access.
Reply content:
Now there is a project on hand that runs a website in an embedded device with a Linux system.
The CPU of the device is RAM structure, single core, 1GB.
We set up a apache+mysql+php in the system and then write a website that runs inside. It feels a bit like the setup of the Web page inside the router, but it's a complete website app.
PHP runs very slowly on the device, but by merging PHP files (reducing IO), using APC (cache opcode and some data and pages), the speed of access is improved.
However, every time you visit the site inside the device, the CPU of PHP-FPM can take up to about 40%, and the CPU consumption will drop when the page is not accessed. Because other services and programs are running on the device, when PHP-FPM consumes too much CPU, it can cause other programs to become problematic.
Why does PHP-FPM occupy so many CPUs? Apache has not accounted for much, there is no way to let the CPU down.
Would have wanted to use some embedded Web server, but feel CPU usage is not the problem of Apache, is the problem of PHP, do not know how to handle. Do you have any suggestions or ideas?
PS: The site in the device has only one user access.
If apache,mysql,php or anything is crammed into an embedded device, it is likely that there is not enough memory or that the cache space is being squeezed out, causing a large number of page fault to be triggered per visit.
Another possibility is that the PM is set to OnDemand or other non-fixed algorithms, allowing PHP-FPM to constantly take the time to start a new PHP process.
I'm not mistaken, php-fpm. When a request is received, the default is to loop through the worker list to find the next idle worker instead of reusing the old one. If you open 10 workers, the new worker may have swapped out memory.
It is recommended to reduce the number of workers php-fpm spawn. For single-core processors, MySQL is deployed on the same device, and even a worker is enough. (No need for I/O wait, more workers are only to carve up 100% of the CPU occupied already, but also create unnecessary context switch. )
Embedded to use Apache + PHP recommended directly with mod_php. If possible replace LIGHTTPD + php-fcgi should be faster.