Symfony2应用程序在每个请求中解析YML [英] Symfony2 Application Parses YML On Every Request

查看:218
本文介绍了Symfony2应用程序在每个请求中解析YML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Symfony2应用程序有一些性能问题,所以我在它上面运行一个webgrind,以查看发生了什么。原来,它正在解析大量的YML文件在每一个请求,我不知道为什么。我已经启用APC缓存,所以我不知道它可能是什么。对这个问题的任何帮助都将不胜感激。



编辑:这是一个我运行的webgrind的屏幕截图。

解决方案

从我的研究中,看起来APCClassLoader不会导致Symfony2缓存在Doctrine中使用的YAML文件。它似乎默认缓存配置文件(config.yml,parameters.yml),但是Doctrine使用的实际ORM YAML文件不会缓存,除非您指定了如下链接的文档中所示的缓存驱动程序:



http:// symfony.com/doc/2.3/reference/configuration/doctrine.html#caching-drivers



所以,上述解决方案可能会解决问题,如果海报只有配置YAML而不是教义YAML。但是,如果涉及到Doctrine YAML,则必须指定一个Doctrine缓存驱动程序。



这也会影响使用注释的用户,因为除了指定了缓存驱动程序(Doctrine默认数组缓存除外)之外,每个页面都将被解析。想想我应该发帖,因为这是一个复杂的问题,上面的答案是误导的,在我的情况下,Doctrine ORM YAML文件是缓存问题的根源。



这篇文章有关于我的具体问题和解决方案的更多细节:



为什么Symfony2应用程序花费70-90%的时间解析YAML?


My Symfony2 application has some performance problems, so I ran a webgrind on it in order to see what was happening. Turns out it was parsing huge amounts of YML files on every request and I can't figure out why. I already have APC caching enabled so I don't know what it could be. Any help with this issue would be much appreciated.

Edit: Here is a screenshot of the webgrind I ran.

解决方案

From my research, it appears that the APCClassLoader does not cause Symfony2 to cache the YAML files used in Doctrine. It appears to cache the configuration files by default (config.yml, parameters.yml), but the actual ORM YAML files used by Doctrine are not cached unless you specify a cache driver as shown in the documentation linked below:

http://symfony.com/doc/2.3/reference/configuration/doctrine.html#caching-drivers

So, it's possible that the solution above solved the issue if the poster had only configuration YAML and not doctrine YAML. However, if Doctrine YAML is involved, a Doctrine cache driver must be specified.

This also affects people using Annotations as they will be parsed on each page load unless a cache driver is specified (other than the Doctrine default array cache).

Thought I should post because this is a complex issue and the answer above was misleading in my case where Doctrine ORM YAML files were the source of the caching issue.

This post has more details on my specific issue and the resolution:

Why is Symfony2 app spending 70-90% of its time parsing YAML?

这篇关于Symfony2应用程序在每个请求中解析YML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆