PHP performance OS - php

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

Related

Moving a PHP Project from Linux to Windows using Docker?

I've been using Ubuntu dual booted with Win 10 for the past 2 years and I absolutely love ubuntu, however, due to my studies, I need frequently to use softwares like Excel, PowerBI, MiniTab, which only work on windows and have no good support through Wine unfortunately.
Currently I'm considering moving back to Windows, it's still good, but I don't want to waste a lot of time configuring PHP and JS for a project I'm working on on Ubuntu.
This project is based on Laravel 8, VueJS and MySQL for the database and I'm looking at the most efficient way to import this project to windows.
Using VirtualBox :
I thought about installing ubuntu as a VM on Windows and reinstall all dependencies on that VM and code directly from the VM, but I have around 8 gb od RAM and a cpu I5 4th gen, with only HDD drive. I don't know if I will be comfortable coding on the VM with these specs, especially I will be running chrome and PHP Storm at the same time on the VM which can get up to 5gb of ram alone back on ubuntu.So I won't have any left for windows.
Any other solution ? I thought about using Docker, I don't know if it's suitable in this case ? like importing the project into a docker container in ubuntu, then move back to Windows and use that docker container in php storm or another IDE ?
I also tried WSL with no success since my linux partition is not a physical one.
What's the best solution given my specs to keep working on this project without leaving windows and can be set up easily ?

Using PHP and MySQL to develop website

I want to develop a professional website using PHP and MySQL. Can i do it in Windows 7 (64-bit) or i need to install linux based OS. How to go for it.
You can run an AMP Stack (Apache, mySQL, PHP) on Windows no problem. I have been doing this for ten years now. Running on Windows 7 64-bit is also no problem.
There are several pre-packaged installers available. My favourite is XAMPP. They usually allow full customization where needed.
You can also download the stand-alone binaries of each product and install them manually. Makes for very, very good learning but is more work.
Yes, you can.
Though a platform is the least thing you will need...
As mentioned it is possible to develop Php and MySQL sites quite happily on Windows using something like XAMPP, even if they are later to be deployed on a Linux web server and I know a lot of people do this and it works great for them.
However I have found in the past you can run into problems later on this way. For example, a lot of people who have only used Windows in the past can get caught out by case-sensitivity in Linux. So your site runs great locally but then you start getting lots of 404 errors when you go live because for example, mypage.php is not the same as myPage.php any more.
At the other end of the development spectrum, you can achieve some really powerful functionality when you start to work the server a bit more - things like video encoding or audio conversion are possible using PHP (with a bit of help from some other apps) on both Windows and Linux but the ways that you would do it are different therefore your development environment becomes much less useful and again you run the risk of putting something live that doesn't work, even tho it runs fine when you test it locally.
Personally, I think it is always best to develop on as close an environment to the intended production server as you can to avoid any nasty surprises when you go live.
Develop on the same platform you are going to be deploying to (if possible). It'll make it extremely easy to deploy with less room for possible error.
Installing the 64-bit versions Apache/PHP/MySQL on Windows 7 is a bit of a pain, but you can easily install the 32-bit versions using XAMPP (as mentioned by Pekka) from apachefriends.org
For Windows you can use a light package, which content php, apache, mysql, pear. link text

PHP, MySQL | Windows vs Linux

Well the title does the explaination. Which one is faster PHP/MySQL on Linux or on Windows.
Question 1
I know that MySQL is slower on Windows, because i tried to run a C++ program on Windows to access MySQL, it took a year every time it had to open a connection. When i ported the exact copy into the linux enviornment it was lightning fast.
Im not sure why the difference is, Maybe cause when we talk about Linux every thing is million times faster, but it would be good to know why such a massive difference.
Question 2
I have set up PHP on IIS and mySQL on Windows ive just tested a very small application on this setup and it seems fine. What i really want to know is that is there any performance issues for PHP in Windows rather than Linux?
Edit Windows Vista Was the OS i tried on Originally, Havent Tested W7. Fedora 10 was the Linux :D
They should be the same speed eventually. If you do an unscientific, unfair test, you might show a difference.
Process startup speed might be different. In particular, process startup might be slower on Windows. This shouldn't matter too much in production unless you're using a model which creates new processes on a very frequent basis, which will be inefficient on either.
Run a performance test of your actual application, with a large number of requests, over a significant length of time, on production-grade hardware. It's the only way to tell.
Needless to say, I can safely say that almost nobody chooses Windows vs Linux based on performance. Usually it's what they are capable of managing in production and have hardware / software support for.
If you're going to install 1000 boxes in production, Windows server licencing might get expensive (depending on your deal with MS). If you are only going to install a few, it probably doesn't matter (supporting the servers will be much more expensive).
Things are slowly getting better on Windows, with IIS 7 and PHP as a FastCGI ; see http://php.iis.net/
But I have never heard anything good about PHP + IIS6... Never worked in this configuration myself, though ; so I can't speak of experience.
One thing to consider is that Windows still (things are slowly getting better too) seems to be considered as a second-class citizen, when it comes to PHP...
And it's harder to get exactly the version of PHP you want (on Linux, you just recompile, and that's definitly not hard at all) ; even more for PECL extensions, btw...
As a sidenote : you can run PHP on windows with Apache ;-)
PHP is just about equally fast on Linux and Windows, variations among different functions.
PHP on linux used to support more functions Windows did not like pcntl_fork and socket_create_pair. It seems that with the release of version 5.3 those now works on both (from the PHP documentation).
I dont know about any speed difference between Apache on Linux vs IIS, or Apache on Linux vs Apache on Windows.
1) This is probably due to your mysql server trying to do a reverse lookup, and/or your DNS for localhost on the windows machine being incorrect.
2) PHP is the same speed, overall, however, the interface to it (apache module, cgi etc) may not be as fast.
Not sure what the issue was unless you had many of concurrent connections and/or were not running on windows server. There should be no noticeable speed difference between the two. There was something else going on in your program.

Which Linux distro is best for running in a virtual machine, for programming research?

I'd like to learn LAMP development for my own personal edification.
I tried setting up Ubuntu 8.10 "Hardy Heron" in Microsoft VPC, but I can't get the video to work above 800x600. Played with xorg.conf a million times but no joy. Can anyone recommend a good distro to work with that plays well with VPC? Any guidance on getting started with Apache and Perl/PHP would also be welcome.
I installed ubuntu 8.10 in a virtual machine on my Vista 64-bit laptop. I attempted the install with Virtual PC, VM Ware and Virtual Box from SUN. Virtual Box was the only vm software that I was successful with from the start. In the setup you choose that you are installing linux as your guest OS and everything works without spending your evening sifting through blogs trying to get install to work.
Firstly, if your goal is to learn LAMP development, I'd start by just downloading the WAMP stack for windows from http://www.wampserver.com/en/ or one of it's competitors. The "Linux" part of LAMP programming isn't likely to be a major part of your learning experience. Avoiding running a VM will be much less resource intense on your development workstation and avoid having issues with suspend/resume and disk IO contention.
Secondly, any linux should work, under virtualbox or msvpc. All the modern desktop virtualization systems emulate a full system, so it's just a matter of configuration and getting the right drivers. Like others said, virtualbox is more open source friendly so give that a shot.
Finally, I don't usually run X on my development VM's, since it just eats unnecessary resources. Just use putty on the host and ssh in to a VM running in console mode.
Not entirely the answer to your question, but I think it attacks your goal more directly.
If you're not wedded to VPC, a quick way to start might be to download the free VMWare Player at
http://vmware.com/products/player/
and then you can try any of many, many distros prepackaged for VMWare here:
http://vmware.com/appliances/directory/cat/508
The appliances at the second link should work out of box, so you don't have to fiddle with X conf files, which is probably not the topic of your research. As a bonus, you may be exposed to distros you normally wouldn't know about.
Edit: Here's an appliance with Ubuntu 8.10:
http://www.vmware.com/appliances/directory/54735
http://www.virtualbox.org/wiki/Guest_OSes
This is largely a matter of preference. As has been mentioned, Ubuntu is a good choice. I tend to prefer debian as it is a bit less cutting edge (and therefor more stable). But it's not as easy a platform to learn as Ubuntu.
As has also been pointed out, I would recommend VirtualBox as Virtual PC doesn't support non-MS operating systems.
I use Ubuntu 8.10 and Mono.
However, to get the graphics to work properly, you need the
noreplace-paravirt
kernel parameter.
I use Scientific Linux 5.2 (which is just a rebranded RedHat Enterprise Linux 5.2) and it works fine. I also have had success with many flavors of Ubuntu. I run all of my machines under VMWare Server and have successfully used them with both the 1.0.x versions and the 2.0.x versions of VMWare server.
Does it have to be Microsoft Virtual PC? Virtual Box is much more open-source friendly and I used it with no problems to display higher resolutions of the guest OS.
Check Bitnami stacks. They are ISO live disks images. You just need to attach the iso to the boot cd of the vistual machine. There is a LAMP stack based on Ubuntu.
If you like how it works, there is an option to install to a virtual disk.
I was able to get VMWare Server (free) to work fine with Ubuntu without much hassle (display, etc works out of the box). Install VMWare tools on the VM (they make it for linux) and you'll get a more seamless experience. My specific configuration:
VMWare Server 2.0
Host OS: Windows XP Pro, SP 3
Guest OS: KUbuntu 0804

PHP website, should I develop into a Linux distribution instead of Windows?

In few months I start a project in PHP and I am hesitating to do like usual : develop on my Windows Vista 64bits machine. Since I know few things on Linux, I think it can be a good way to learn by working on a Linux distribution.
Do you think it's a good idea or not? I would run a VirtualBox with Ubuntu (on my Vista64bits). I was thinking to install XAMPP to be able to develop in PHP.
If you think it's a good idea, feel free to suggest me some tutorial about what I should know with Virtualizing an OS, or Linux/dev.
Update
I have build many website in PHP with Windows, the question is more about if it's a good way to start learning Linux by developing on it via a Virtual machine? I have 4 gigs rams, will it be smooth if I install Eclipse in the Virtual Machine? etc.
You should really develop on the same platform where you are going to deploy. I'm not saying it is bad to do differently, but it can save you some pain in the long run. OTOH, you might learn faster about platform differences that way. So, the main question is: do you want to have a production system running ASAP without much headache? Or, you want to spend some time and make some effort to learn how to develop cross-platform stuff?
And yes, there are differences. For example, case sensitive and case in-sensitive filenames. Then, some PHP functions use native C functions that have different implementation. For example, printf() does not produce the same amount of whitespace for some of the types. Resolution of time measurement (milliseconds vs microseconds) can be different, etc. Then, you have different ways filesystem permissions are handled. These are just some recent problems I've found that I can remember off the top of my head.
PHP should be the same on any platform - so where you develop shouldn't matter.
However, in my experience and observation,more sites running PHP are running on Linux than Windows.
Getting Apache and PHP setup on something like Ubuntu or Fedora is a cinch, and testing everything is pretty simple, too.
Also, when you go live with your site, what platform will it be running on? I prefer to do development on the platform it will be running on whenever possible.
Personally, I don't think that for local production you should be using a VM. Would you be running your IDE inside the VM too?
If you are aware enough of the pitfalls of moving between Windows and Linux environments (such as case sensitivity and permissions), you should have no problem developing on Windows and deploying on Linux.
Working on a Linux distribution is defnitely the easiest way to learn it. And setting up some servers and doing some dev work is an excellent start.
Virtualising Linux is also really easy. I've done it quite a few times and it's really obious. Also, going this way will ease you into using Linux, much better than just jumping in and finding out your wireless card is unsupported like I did :)
As for PHP development on Linux... I've done some PHP coding on Windows and on Linux and I can tell you there's very little difference between the two. I use Eclipse on both platforms and Apache &MySQL / XAMPP. The only major difference I've seen is that Linux is much more finicky about permissions and case.
PHP is not the same on all platforms, and until very recently the windows versions had problems which were not found in the Linux versions. Lots of useful features are *nix specific.
I would echo #Milan's sentiments about developing in the deployment environment. You learn a lot more about the deployment environment by doing so too.
On the VM issue, if you want all your Windows tools and your windows machine, setup a linux server in your VM (can have a GUI if you want, but you're going to mainly use it as a server). Set it up so that windows can view the apache install running in your VM and you use samba shares to access the vm's files like a drive in windows. That way, you develop in windows but are testing deploy / setup on a running linux server. While two devs at my shop run Ubuntu, a third needs to use Photoshop and various other bits of windows software all the time, so she uses this method of running a server in a VM but developing from windows.
Oh, and if you're running on Linux, don't use XAMPP! A few simple commands will have you up and running and you'll get a much better understanding of your deploy. XAMPP is fine, but it's for OS's that don't have Linux's package management.
while XAMPP works great, running Apache and PHP on Linux is a given; while on Windows it's something extra you have to do... and support. Also, most parts of the stack are far more optimised and mature for a POSIX environment. The database engine(s) performance is particularly sensitive to the available primitives.
Most OSS runs on windows, but it's a round peg whammed on a square hole.
On principle, I would advise against "learning by doing" in a real project - unless it it really small, or you have doen very similar projects before, so that the learning curve on project related issues would not be steep. In that case you may have ressources free for learning about the developing environment.
Generally I like the Linux environment better than Windows. Mainly because all the CLI tools you would need are provided and Bash beats cmd.ext any time. But with Cygwin I find even Windows a comfortable development environment.
Regarding PHP development I can't really see how it would be much different. Maybe there is some benefit in being forced to make the code more portable (things like line endings, forward slashes in filenames and such) if you use booth systems.
As a desktop or workstation there isn't much difference between the two. I find that the biggest differences lies in how you administer them, but hopefullt you have some other people doing that for you.
In my opinion you needn't to develop in a linux distribution.
Web Development can be done from any OS. I don't know, why you are programming for the web... as a professional? for your personal homepage?
I think, it's enough to get some free webspace running a PHP Server and to upload your files there... it doesn't take you much time and there are less things to manage.
a german student ;)
Use the OS your deployment server will be running, and it is highly probable to be linux. I have recently seen a deployment gone ultra bad cuz it was developed using wampserver and deployed on CentOS. With major differences in apache and PHP config. So know your deployment server and match it as closely as possible.
Try creating a development environment using VmWare Player. I have several Linux environments that I run on my Vista laptop. You could also just dual boot. I use Ubuntu, it is easy.
The side effect of developing inside a VM: more overhead and eventually the needs of additional tools to make the development more comfortable.
Often people need special tools for their development like Photoshop or some vector design tools not available on Linux. If the working copy of the project is inside the VM, it makes sense to have easy access to it. So you will setup SAMBA (which makes often problems with the login from XP) or setup SSL(SFTP)/FTP.
Also you must learn how to use networking with the VM (NAT, bridging, port forwarding).
On the other side, developing on another platform as the target can give some headache. I found myself often confused with .htaccess files for password protection, because oft the different path on Windows/Linux. If you forget to change this entries later on the production server, you have a problem...
A better solution: use the best of both worlds.
A VM eventually running later headless (no gui, more like a "remote server") with Ubuntu/Debian/FreeBSD) and only running the needed servers (Apache, MySQL, FTP, SSH...).
Eclipse or the other development tools on Windows/Mac.
5 years later: My opinion is to use the Linux solution. There are many advantages for using PHP in Linux. The primary reason is the level of help available from the community. PHP seems to be optimized for Linux environments as well.
There is also safety in numbers as an overwhelming number of sites are hosted and run with LAMP solutions. There are a wide range of frameworks and CMS' that run best on Linux with Apache2.
Make your life easier and start learning PHP straight away.

Categories