简体   繁体   English

Symfony2加载时间和性能

[英]Symfony2 loading time and performance

I am working on a not so big project (3 bundles I created and 6 I downloaded / 5 Entities) and I have placed this code on my home controller : 我正在开展一个不太大的项目(我创建了3个包,6个下载/ 5个实体),我已将此代码放在我的家庭控制器上:

class HomeController extends Controller
{
    public function indexAction()
    {
        $time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
        echo $time; 
        die();

        //...

It's giving me under 100ms on the localhost (with APC enabled) which is fine. 它在localhost(启用了APC)上给我100毫秒以下 ,这很好。

The real problem is the behavior on the online server (using prod env and APC not installed) : If I don't use the website for like 10 minutes, the first time it is really slow to load ( 2 to 4 seconds ) and then if I stay on the website, if I refresh the page, it is way faster ( from 500ms to 1s ). 真正的问题是在线服务器上的行为(使用prod env和APC未安装):如果我不使用网站10分钟,第一次加载真的很慢( 2到4秒 )然后如果我留在网站上,如果我刷新页面,它会更快( 从500毫秒到1秒 )。

Is that normal ? 这是正常的吗? Is there something wrong with my online server or my symfony2 project ? 我的在线服务器或symfony2项目有问题吗?

You should definetly setup APC to decrease the loading time. 您应该明确设置APC以减少加载时间。 Here's a note on that: 这是一个关于此的说明:

Performance 性能

(2015 edit: link updated) (2015年编辑:链接更新)

Just have a look at the timeline tab of the great toolbar / profiler which Symfony provides: http://symfony.com/blog/new-in-symfony-2-2-new-stopwatch-component (not limited to 2.2) 只需看看Symfony提供的伟大工具栏/分析器的时间线选项卡: http//symfony.com/blog/new-in-symfony-2-2-new-stopwatch-component (不限于2.2)

Are you using localhost as the database_host? 您使用localhost作为database_host吗? If so, try 127.0.0.1 instead! 如果是这样,请尝试127.0.0.1!

Are you accessing a third party API like Facebook (FOSUserBundle)? 您是否正在访问Facebook(FOSUserBundle)等第三方API?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM