php window 4~5 times slower in windows than linux - php

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

Related

PHP performance OS

I'm not used to ask question on forum but this one is out of my scope.
Here is my discovery :
php performances are way different on depending of OS.
Here is the experiences :
I used a brand new Laravel projet from the official documentation (I guess you can do the same with Symfony or even any PHP projet)
I used a profiler Laravel debugbar (I guess you can use any profiler you want or even browser inspector)
I deployed the projet on Windows, MacOs and Linux virtual machine (linux VM is hosted by the same PC than the one for the test on Windows)
I tried with the same PHP configuration
I disabled windows defender
I tried with PHP NTS and TS on all machines
Here are the results :
The loading basic page of the dashboard takes around
200ms on Windows
20ms on MacOs
20ms on Linux Virtual machine
Basical Windows is 10 times slower than the others OS
This is related to the performance os the CPU since Linux VM is 10X times faster than Windows on the same machine
Here is my guess :
PHP build are different depending of the OS (of course) and the one for Windows is defensively not as performante as the others (sad story)
Windows use something on top of PHP that makes it slower.
Here are my questions :
What is causing that lack of performances on Windows ?
Is it possible to run PHP faster on Windows ?
Please give constructive answer :
Windows is bad is not an answer
Windows use services that slower PHP execution without giving any name of services nor program is not a constructive answer.
Giving more tests to do to get interring result is a constructive answer.
Thank you for your help
Maybe this answer can solve your problem. The different file system on Windows and Unix/Linux.
php window 4~5 times slower in windows than linux

PHP Laravel memory usage increase on Direct Admin server

We have developed Laravel based software, locally tested with Laravel Valet and everything is working fine. One installing on a staging (direct admin) webserver with exactly the same database and code the memory usage dramatically increased.
Local testing specs:
OS: MacOS Catalina
Proc: 2.3 GHz 8-Core Intel Core i9
Memory: 16 GB 2667 MHz DDR4
Staging server specs:
OS: CentOS 7.0 64-Bit
Processor Speed (MHz) 2693.670
Total Memory 1014728 kB
This is a basic static page:
Staging server: 21MB, PHP 7.4.2
Development machine: 5MB, PHP 7.4.4
Another larger page (which needs optimization):
Staging server: 101MB, PHP 7.4.2
Development machine: 85MB, PHP 7.4.4
We know this development machine is a lot slower but we cannot explain the memory usage increase. Does anybody know how to analyze and resolve this?
The used framework is Laravel v6.18.20
Well Laravel Valet uses a very lightweight web server and that is a huge difference, I suggest to configure your webserver to use Nginx instead of Apache and be sure you are using PHP as FPM module, generally speaking, servers with Direct Admin uses Apache webserver by default and that will increase the memory usage of every request.
Try to switch to an Nginx webserver

Is it possible to use use Nginx 32bit with php 64bit?

Am new to PHP and Nginx web server. I want to setup a 64bit Nginx web server with PHP 5.6 64bit on Windows 64bit system, but only 32bit Nginx build is available for windows officially. Is it possible to use PHP 64bit with Nginx 32bit web server?
If it is possible to use it, is there any performance impact?
There are 64bit Nginx builds available from unofficial sources, but they advice not to use this for production, so I need to stick with official 32bit Nginx build for windows.
Thanks in advance.
PHP with nginx would normally be run as a fastcgi application (https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/ ).
This would communicate over a TCP socket on windows - and therefore it doesn't matter whether it's 64bit or 32bit php at the far end.
In terms of PHP, if performance is a key driver, and your new - you mind want to consider looking at php 7 as that has a number of performance improvements over the php5 series. The development of php 7 has some benchmarks on a google docs spreadsheet at the bottom of their page https://wiki.php.net/phpng which indicates the differences

WAMPSERVER 2.2 with PHP 5.4 is Running slowly on windows 8 pro 64 bit O.S with x64 processor

The WAMPSERVER 2.2 with PHP 5.4.3 AND MySQL 5.5.24 is Running very slowly on my PC, It's just hangs after some time.
My PC configuration :
Windows 8 pro
64 bit OS
x64 processor
2GB RAM.
I am not getting what is the problem behind that What is the solution for that ?
Windows 8, in 64-bit and 2GB ram? Are you seriously asking why this is slow?
64-Bit OS requires the doubled amount of RAM for every program than a 32-Bit OS.
And windows 8 is a pretty new OS in a time where PC's with 4GB RAM became somewhat standard.
Open a few programs and 2GB are full, how do you expect Apache AND MySQL to operate there manually?
For example I have a PC here with 8GB ram currently running MYSQL, Apache, PHPStorm IDE, Thunderbird, Firefox and Spotify and I am # 4,6 GB RAM usage. Even if I close browser, IDE and spotify it wont go below 2GB.
There is no way to solve this except buying better hardware.
Oh and a SSD could help alot aswell but wont be sufficient alone in your case!

Why does a PHP-request consume much more memory on a different server?

I'm having a PHP script that's running fine on my development server (Linux Debian Squeeze 64-bit, PHP 5.3), according to memory_get_peak_level() it's roughly consuming about 13M of memory.
When I run the same script on a production server (also Debian, PHP 5.3) I sometimes get a fatal out of memory error as the script is trying to allocate more than 256M (the limit that has been set in memory_limit), reproducable. It's a database driven application (MySQL) and I mirrored the database to ensure it's not the data that's causing trouble.
Are there any good strategies to find out, why it's consuming more than 10 times more memory? What could be possible causes for that? Can it be the ioncube extension I'm using on the live server?

Categories