用于 Symfony2 性能的 Sonata Admin [英] Sonata Admin for Symfony2 performance

查看:44
本文介绍了用于 Symfony2 性能的 Sonata Admin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Symfony2 的新手,我必须承认我很喜欢它.我开始玩 SonataAdmin,但很快就出现了一个主要的疑问:加载列表页面需要近 3 秒(使用空数据库)是否正常?我知道在生产中我应该使用 APC 或 memcache 来加快速度,但对我来说这看起来很奇怪,需要很多时间.

I'm new to Symfony2 and I must admit I'm enjoying it. I started playing with the SonataAdmin but soon a major doubt popped out: is it normal it takes almost 3 seconds to load a listing page (using an empty database)?? I know in production I should go for APC or memcache to speed up things but it looks strange to me it takes so much time.

我正在使用带有 Turnkey 灯(1GB 内存)的虚拟机进行开发.

I'm developing using a virtualmachine with Turnkey lamp (1GB ram).

我的电脑相当新:Intel i3 8Gb 内存.

My PC is fairly new: Intel i3 8Gb ram.

请告诉我您的想法/经历.

Please tell me what you think/experience.

谢谢.

推荐答案

在开发环境中,很难衡量性能,因为框架和捆绑包有时需要解析大量配置文件、内省对象和执行耗时的任务并缓存输出.

In development environment, it is hard to measure performance because the framework and the bundles sometimes need to parse a lot of configuration files, introspect objects and perform time consuming task and cache the output.

在生产中,很多事情都是预先完成的,即当您部署到 Web 服务器时.前期工作是为了避免解析文件、执行耗时的任务等.这就是为什么在生产中,如果不运行 php app/console clear:cache 之后几乎无法更改任何内容修改已经完成.即使更改单个 Twig 模板也需要清除缓存以更新呈现给最终用户的输出.

In production, a lot of stuff is done upfront, i.e. when you are deploying to your web server. The work upfront is done to avoid parsing files, do time consuming task, etc. This is the reason why in production, you almost can't change anything without running php app/console clear:cache again after the modification have been done. Even changing a single Twig template requires a cache clear to update the output presented to the end user.

我没有亲自测试这个包,但是管理生成器包需要检查很多属性和对象才能正确执行他的任务.这确实很耗时,但这仅在开发模式下才需要.在生产中,这种内省过程不是必需的,信息可能缓存在某处.这在生产环境中应该比在开发环境中表现更好.

I did not test this bundle personally, but an admin generator bundle needs to check a lot of properties and objects to perform his task properly. This is indeed time consuming but this is required only in development mode. When in production, this introspection process is not necessary and the information is probably cached somewhere. This should give way better performance in production environment than in development environment.

最重要的是,我不认为这个包会遇到性能问题,但这取决于您的需求和目标.我唯一可以确定的是:在生产模式下测试它,看看它最终会给你带来什么样的速度.清除生产模式的缓存并使用 app.php 而不是 app_dev.php.另外,请查看 symfony.com 上关于 performance 的文档.

Bottom line, I don't think this bundle suffer from a performance problem but this depends on your needs and objectives. The only thing I can be sure of: test it in production mode to see the speed it will give you in the end. Clear you cache for production mode and use app.php instead of app_dev.php. Also, check the documentation on performance that can be found on symfony.com.

php app/console cache:clear --env=prod --no-debug

希望这会有所帮助.

问候,
马特

这篇关于用于 Symfony2 性能的 Sonata Admin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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