I'm running Symfony's built-in server during development and noticed that CPU usage of CLI.exe (PHP's command-line interface that's called through php bin/console server:run) is always around 30%, even when idle.
I launch it from a Windows Powershell. Any idea why this happens during idle time?
PHP's built-in web server is only meant to be used during development:
Warning This web server was designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.
It makes no performance guarantees, and I'm not surprised that it has high CPU utilization.
The Symfony documentation suggests that it is only meant as a convenience:
This way, you don't have to bother configuring a full-featured web server such as Apache or Nginx.
Of course, you are free to run a full-featured web server in development if you want something more tuned to real world use.
Related
We have been running our PHP applications on CentOS \ MySQL dedicated servers for sometime.
However, I now have a requirement from a client that we are highly fault tolerant and able to scale up quickly and easily.
What is involved in migrating from a dedicated Linux server environment to cloud based technology? Is it a steep learning curve or are most of the differences under the hood.
You can easily take your PHP application to cloud by creating your own PaaS. Apache Stratos is a PaaS framework which allows you to do so. It has out of the box support for PHP and MySQL (those are called cartridges). It guarantees high availability and autoscaling support and also load balancing. You dont need to change your application code either.
I originally started developing PHP via WAMP/MAMP stacks. These work, but there are a lot of painful caveats to deal with.
More recently, I've begun working with other software stacks, like rails, that can run the server from arbitrary directories with a minimum of configuration, muss, or fuss. Just a simple rails -s or python -m SimpleHTTPServer 8000. (OK, the second one might not be simple).
Unfortunately, the rails one is for running a rails server. The python one sets up a very simple HTTP server. Neither one is appropriate for running PHP code.
Are there any alternatives out there to run a PHP based server from an arbitrary directory -- in this case, the development directory of the app I want to work on? I'd strongly prefer Mac OSX, but if there's a windows version available as well, I'd love to hear about it.
As of 5.4, PHP includes a built-in web server that can be used for development.
For example:
php -S localhost:8000 index.php
Documentation: Built-in web server
But keep in mind:
This web server was designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.
We've been battling this problem for some time now, and can't seem to find a perfect solution that would satisfy all the requirements of making life easier for developers.
Right now we have the following setup:
Linux development server (as everything we produce runs on linux, and it uses some linux-specifix libraries)
Windows desktops (as the office network is on windows)
Every developer has a home folder on the dev server with a virtual host set up to run their code. This folder is shared using Samba.
Zend Studio IDE that is set up to use that location (as a network drive) to work on projects
Remote debugging to be able to run applications on the dev server and be able to step through the code
So the main problem we are having is that everything is slow...
Zend is slow to index the project, as it has quite a bit of files (including externals like full framework) that need to be transferred through SMB.
Remote debugging is slow, as Zend studio needs to fetch the file, then send it back to the server to run it (running "Local if available, else server"; otherwise breakpoints don't work)
Tortoise SVN is slow to get file status for the commit (command line remedies the problem, but it's much less user friendly, especially with more complicated things like conflict resolution while merging)
Branching out to any of the solutions that would have multiple server configurations brings up a problem that there is a chance of having different configurations everywhere, which will introduce additional layer of uncertainty and possibly bugs in production.
Development and debugging under windows is not possible because of linux dependencies in the code (like POSIX functions).
So how do organizations solve these problems? What kinds of set up are you using? What kinds of problems are you facing, and how to you resolve them?
One solution that works in some situations is to :
Have the code on your local disk, on the physical computer running windows
This code is the one you're modifying with your IDE
So, IDE is working as fast as possible : no SMB access for each file.
Also have the code on the Linux server
So Apache runs fast : the code is present on the server
Use some kind of synchronisation mecanism, to push every modification made on a file on the Windows machine to the Linux server, via the SMB share.
Using Eclipse, the FileSync plugin does a good job, over the SMB share.
WinSCP can also be used, to keep a remote and local folder synchronized, over an SSH connexion
Advantages :
All local operations are fast
All server operations are fast
Drawbacks :
You must always use the tool that ensures synchronisation (For instance, with FileSync, everything must be done in Eclipse -- and nothing in any other software)
Note : for SVN, no need to use Tortoise : there are plugins that integrate into Eclipse (Subversive, for example)
Not sure about debugging
Modifications done directly on the Linux machine might not (depending on the solution) get synchronized to the windows desktop.
Still, the best (fastest and most powerful) solution is generally to use only one computer -- that would run Linux, in your case, and not Windows.
Your tools will most likely work under Linux
If needed, you can install Windows in a Virtual Machine, for some software that don't run on Linux
It'll encourage everyone in your team to know Linux better ; which is always useful, when your production environment is not Windows ;-)
I have written a simple web application mostly full of static web pages with several you-tube embeddings. Few forms and so on. All this is developed using CodeIgniter.
The site is very similar to Academic Earth. With videos served from Youtube. It has got 400 users only 30-40 are active.
I am not interested in shared hosting and want a machine with root access. My budget allows me to hire RackSpace cloud server with 256MB Ram.
Is it sufficient to run my application?
Or should this question go on ServerFault.
Yes, you can run a simple server on 256MB RAM. You would want to look at things like http://www.lighttpd.net/ instead of Apache and do some tweaking to settings (I read that Debian is better at using less RAM out-of-the-box though not sure how true that is.)
Read this:
http://www.lowendbox.com/blog/yes-you-can-run-18-static-sites-on-a-64mb-link-1-vps/
I've had great success running apps on tiny VPS hosts like Slicehost and Linode.
You'll probably be fine with the apache/php/mysql from your distribution's package manager. I've had good results compiling my own AMP stack from source and tweaking things. With PHP 5.3.3, PHP-FPM (FastCGI Process Manager) is built in, and provides much better FastCGI support.
Running PHP under FastCGI can be adventageous in low-memory situations, since you can then run apache with the worker MPM, which is much more efficient, memory-wise than running prefork-apache/mod_php
Note that currently, Linode will give you a 512MB server for $20/month. However, my experience has been that Linode has semi-frequent network issues (see http://status.linode.com), but otherwise they've been great.
If all you can afford is $20/month, you probably can't do much better. The other nice thing about these VPS hosts is that if you need to grow later, all it takes is a couple of clicks in a control panel and you can upsize your server.
Does anyone know of any links to realistic performance comparisons of IIS vs. Apache for PHP hosting?
I am looking to utilise existing infrastructure for a change of technologies from .NET to a PHP application but I cannot find any information about PHP hosted on varying platforms. There is heaps out there about IIS vs. Apache in general, or ASP.NET vs PHP .. or any other language server vs server, language vs language but no server/language vs server/language.
My current direction is to use PHP with FastCGI.. looks pretty good. Just need to justify it or find a compelling reason to reject the big cuddly MS monster that I'm used to.
UPDATED
Windows environment would be Win2k3 running IIS6 with FastCGI serving the PHP extension. Also planning to use eAccelerator or similar script cache.
PHP Best Practices article -- Differences between PHP on WIMP and PHP on LAMP
Some of the differences you may encounter when developing with PHP on Win/IIS vs Linux / Apache.
The most obvious difference between WIMP and LAMP is definitely performance.
For years there has been an obvious performance advantage of LAMP over WIMP.
Only recently is their even a chance of closing that gap.
There are currently 2 projects underway that may help.
Currently available is IIS7 which is reported to have had PHP performance
enhancements built in with collaboration from the ZEND team.
An upcoming projects involves Microsoft engineers working with PHP engineers to get the next version of PHP (PHP5.3 which is not yet available at this time) to perform much better in IIS. This will no doubt make some progress toward WIMP catching up with LAMP in performance.
FastCGI on IIS will significantly increase the performance and will be comparable to that of LAMP. The difference will be in details, which are hard to pick and depends on what your configuration is and on what you scripts do. For example, file access on Windows is much slow than on Linux because of NTFS's ACL checks.
There is nothing particularly wrong with the Windows web stack. The only big reason I'd think of using Windows over Linux when human experience doesn't matter would be SQL Server. Otherwise WAMP, WIMP and LAMP perform comparably and performance differences won't show up until heavy load.