Why is Symfony 2 responding EXTREMELY slowly in my environment?
Asked Answered
H

2

7

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

Harker answered 18/4, 2013 at 19:37 Comment(3)
And if you hit config.php you get no warning?Gyve
@cheesemacfly: No, only the usual recommendations to disable short open tags and install a PHP accelerator.Harker
@cheesemacfly: Interestingly though, the config page loads just as quickly on both locations.Harker
V
7

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.

Visual answered 19/4, 2013 at 1:9 Comment(3)
In my case, I have both open_basedir = none and safe_mode = off, still I see no performance improvement.. APCu is enabled (confirmed with phpinfo), any ideas what else could be wrong?Grum
Is this across a symlink? Is it fast locally?Visual
(1) Yes. /var/www/my-project (root dir in nginx config) is a symlink to the real path (2) it's only run locally so far - I'm trying to make my development enviroment run faster (right now im getting 7~12 seconds in dev which seems too much)Grum
S
3

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

Shala answered 18/12, 2013 at 12:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.