Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Symfony 2 responding EXTREMELY slowly in my environment?

I have a VMware virtual machine running Debian Squeeze. All my projects are in a folder on my Windows machine, accessible to the Debian VM via a VMware shared folder. This means that I can work on my projects using a proper text editor on my Windows machine while hosting them from a linux environment. I've been using this setup for months, having no problems hosting Apache sites with PHP or other development related tasks, until I tried out Symfony.

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

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

Symfony is an actual physical directory sitting in the htdocs folder, while Symfony_shared is a soft link to the Dropbox folder on my Windows machine. I must repeat; I have never had any performance issues with this approach before.

Same file system

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

Total time           83 ms
Initialization time  43 ms

Very nice 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 anybody explain these numbers? What is the "Initialization time" and how come it takes more than 4 seconds? Keep in mind this is just the Symfony demo welcome page. The login page in my actual test project has an initialization time of 19 seconds, the total time being 22 seconds.

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

The only change I've made to the Symfony folders is removing the portion of app_dev.php that limits traffic to 127.0.0.1.


I'm using Apache 2.4.4 and PHP 5.4.14 on Debian 6.0.7 (squeeze).

Here is a screenshot of the Symfony_shared welcome page profiler:

Screenshot of the Symfony_shared welcome page profiler

like image 902
Hubro Avatar asked Apr 18 '13 19:04

Hubro


2 Answers

Check your PHP configuration for open_basedir restrictions preventing your stat cache from working. Symfony makes a LOT of fstat() calls and if those aren't cached Symfony is extremely slow. It's possible your symlink is also preventing the stat cache from working. If you profile your app (and include native PHP functions), it will be pretty obvious if it's fstat() that's causing your issues.

There's some information about it at PHP Bug #49383.

like image 154
Ryan Avatar answered Nov 16 '22 02:11

Ryan


Try to set PHP.ini's realpath_cache_size to a value > 1000 A symfony requirement was recently added fixing this issue: https://github.com/sensiolabs/SensioDistributionBundle/commit/cf0179711b24d84d4a29d71a4010540f4c990bd8

like image 39
Nanocom Avatar answered Nov 16 '22 02:11

Nanocom