Why does Symfony 2 respond extremely slowly in my environment?

I have a VMware virtual machine with Debian Squeeze. All of my projects are located in a folder on my Windows machine, accessible to the Debian virtual machine through the VMware shared folder. This means that I can work on my projects using the correct text editor on my Windows machine, placing them in a linux environment. I have been using this setup for several months without having problems hosting Apache sites with PHP or other development related tasks until I tried Symfony .

Now I have one instance of the finished Symfony 2 demo ( Symfony_Standard_Vendors_2.2.1.tgz ) in my htdocs directory, as well as one on my Windows machine shared with VM. My htdocs directory looks like this:

htdocs |`- Symfony `- Symfony_shared -> /mnt/hgfs/Dropbox/Symfony 

Symfony is the actual physical directory located in the htdocs folder, and Symfony_shared is a soft link to the Dropbox folder on my Windows machine. I have to repeat; I have never had a performance problem before.

Same file system

Now - when I visit http: //devmachine.local/Symfony/web/app_dev.php in the browser and go to the profiler, I see these numbers:

  Total time 83 ms
 Initialization time 43 ms 

Very good numbers. The entire response was ready in less than 100 ms.

Linked

But when I visit http: //devmachine.local/Symfony_shared/app_dev.php , I see very different numbers in the profiler:

  Total time 6833 ms
 Initialization time 4249 ms 

Can someone explain these numbers? What is “Initialization Time” and how does it take more than 4 seconds? Keep in mind that this is just a symfony welcome page. The login page for my actual test project has an initialization time of 19 seconds, the total time is 22 seconds.

I should mention, I also performed a quick test with running php app/console in both directories. In the Symfony folder, this command immediately returned usage, and in Symfony_shared, it took a few seconds before replying.

The only change I made to the Symfony folders was the removal of the app_dev.php part, which limits the traffic to 127.0.0.1.


I am using Apache 2.4.4 and PHP 5.4.14 on Debian 6.0.7 (compression).

Here is a screenshot of the symfony_shared welcome page profiler:

Screenshot of the Symfony_shared welcome page profiler

+6
source share
2 answers

Check your PHP settings for open_basedir restrictions that prevent you from working with the stat cache. Symfony makes LOT calls to fstat() , and if they are not cached, Symfony is very slow. Perhaps your symlink also prevents the stat cache from working. If you profile your application (and include your own PHP functions), it will be pretty obvious if it fstat() is causing problems.

There is information about this in PHP Error # 49383 .

+6
source

Try setting PHP.ini realpath_cache_size to> 1000 Recently a Symfony requirement has been added to fix this problem: https://github.com/sensiolabs/SensioDistributionBundle/commit/cf0179711b24d84d4a29d71a4010540f4c990bd8

+3
source

All Articles