Symfony2 Slow Initialization Time

前端 未结 9 1666
一生所求
一生所求 2020-11-29 15:32

I have Symfony2 running on an Ubuntu Server 12.04 (64-bit) VM (VirtualBox). The host is a MacBook pro. For some reason I am getting really long request times in developmen

相关标签:
9条回答
  • 2020-11-29 16:19

    I had problems as well with slow page loads in development, which can extremely frustrating when you're tweaking CSS or something similar.

    After a bit of digging I found that for me the problem was caused by Assetic which was recompiling all assets on every page load:

    http://symfony.com/doc/current/cookbook/assetic/asset_management.html#dumping-asset-files-in-the-dev-environment

    By disabling the use of the Assetic controller I was able to drastically increase my page load. However, as the link above states, this comes at a cost of regenerating your assets whenever you make a change to them (or set a watch on them).

    0 讨论(0)
  • 2020-11-29 16:21

    In app_dev, all the caches and auto loading is starting from scratch and what I found to be most slow in dev is the orm. I shy away from using orm and focus mainly on dbal because of it, although i probably shouldn't. Orm is used quite a bit in sf2. My guess is orm is what's slowing you down most in dev. Look at the difference between your dev config and prod config. However, some tweaks to your dev config can make development much snappier and enjoyable.. Just try and be aware of what your doing. for example, turning off the twig controller and then modifying a lot of templates will be kind of frustrating. Your need to keep clearing your cache. But like you mentioned, its dev only and when its time to go live, symfony will speed up for you.

    0 讨论(0)
  • 2020-11-29 16:30

    We have the same problem. Here we have 10 second and more for every request. I see if I remove following lines in bootstrap.php.cache all times return in normal state (298 ms).

    foreach ($meta as $resource) { 
    if (!$resource->isFresh($time)) {
    return false;
    }
    }
    

    It's possible that we have wrong modifications times, but we don't know how to fix. Somebody know a solution?

    0 讨论(0)
提交回复
热议问题