How can I troubleshoot high CPU usage caused by PHP-FPM on a production server running PHP 8.1 on Ubuntu 22.04 when the same issue is not present on a development server with identical PHP settings? I setup correct values for pm_start_servers etc (https://thisinterestsme.com/php-fpm-settings/ following this)
4 cores, WordPress site with woo-commerce, and 8 GB ram. Ram usage around 30%)
I have migrated the existing application from core php to laravel framework. But the laravel application usage more than 90% cpu for the 100 concurrent users but the same application developed in core php usages the 5% cpu load only for the same load.
Then I have created one sample 'helloworld' application in laravel for load testing and result is the same.
I have tested the laravel application using load testing tool siege, hits url 'siege www.mysite.com/helloworld -c250 -t20s' for 250 concurrent users (duration 20 sec) and still cpu load reaches more than 90% (linux centos 7.5 8 core 8 gb ram apache).
Also tested the core php file 'helloworld.php' using same load testing tool ('siege www.mysite.com/helloworld.php -c250 -t20s') but CPU usage not exceeded even 5%.
I am using the latest php version ie 7.2
linux server centos 7.5 8 core 8 gb ram
apache
Also tried the varnish http cache
laravel version 5.4 (also tried the 5.6 but the result is the same)
I don't know where is the issue I have tried everything but still not resolved the issue. Is there anything missing in the configuration on the server or in the coding end. Please suggest.
I just created a EC2 instance and installed LAMP on Ubuntu 16.04 LTS. I'm using AWS EC2 with 1 core processor and 1GB RAM. I have WordPress installed on it with its default theme. When I scanned my website on pagespeed insights, it is showing that I need to reduce my server response time.
I'm using PHP 7.1 and FPM for better performance and disabled .htaccess, yet no success. I tried finding to tune Apache performance but all the articles are almost same and nothing helped me.
I have a site deployed to both Windows server 2012 and ubuntu 14.04 and there is a significant performance difference. The code base and DB data is exactly the same.
Windows environment
Windows Server 2012 in AWS EC2 t2.medium (dual core 4GB ram)
PHP 5.5 64 bit ts
Apache 2.4.23
Linux
Ubuntu 14.04 in AWS EC2 t2.medium (dual core 4GB ram)
PHP 5.5 64 bit ts
Apache 2.4
Both site have OpCache enabled.
The execution time (sole PHP execution time, excluding all network traffic)
Windows: 2.6-2.8s
Linux: 200-400ms
In windows, what we notice is there is a almost 100% CPU load peak and a 3-4MB IO read peak on single page load.
I have already came across various post in Stackoverflow regarding php performance in windows but we have already applied/tested suggestion from those post to no avil
PHP factor 30 performance difference from Linux to Windows
Windows 7 php + Symfony2 terribly slow
Any advice would be appreciated!
Finally got myself an answer to this
The performance difference is due to php function is_dir() perform terrible in Window
Test1: run simple script to loop 1000 times to invoke is_dir()
Windows: 217ms
Mac: 8ms
Test2: profile the code with xdebug
and is_dir() sit at top of the list for highest execution time
Some other reference also point out the same issue
https://github.com/facebook/hhvm/issues/4431
Hope this post can help others facing the same problem
On my development machine my application used up about 4-6MB of memory per request. After switching to a production machine those numbers went as high as 21+MB per request, without any speed improvement (0.30 - 1.2 seconds, which I really hoped to improve on my production machine). Some portions of application (like database bootstrapping) used up 271KB on a development machine and 2.5MB on the production one, so I'm wondering what could be the reason for this. My application uses Zend Framework 1.10.8 (MVC) and Doctrine 2.0beta4 ORM and PDO_MySQL as a database adapter.
My development machine:
Windows 7 32bit, 1.8GHz Dual Core, 2GB RAM, PHP 5.3.2, Apache 2.2.15, MySQLnd 5.0.7-dev (Zend Server CE)
My production machine:
CentOS 5.5 64bit, 2.66GHz Quad Core, 8GB RAM, PHP 5.3.3, Apache 2.2.16, MySQL 5.1.48
Also, I wasn't really able to find a bottleneck, it's like it's application-wide. Please tell me if I should provide any additional info.
Update:
Zend Server, which I use on my dev machine, has Zend Optimizer+ and APC enabled, and my sysadmin recommended me that I should use eAccelerator, so I followed his advice. However, on phpinfo() I see this:
eAccelerator 0.9.6.1
Caching Enabled true
Optimizer Enabled true
Check mtime Enabled true
Memory Size 16,777,144 Bytes
Memory Available 16,772,976 Bytes
Memory Allocated 4,168 Bytes
Cached Scripts 0
Removed Scripts 0
Does that mean it's not properly configured?
Windows 7 32bit,
CentOS 5.5 64bit,