Use Symfony forms carefully
Symfony form is one of the most useful and complex features of Symfony framework. Forms can handle almost everything you are doing like sub-forms, the collection of fields, validation based on condition, reusable fields, auto data rendering and value selection for fields.
In earlier Symfony 2 version there were some performance issue if you do not use proper symfony standards in forms. In the new version of Symfony they have optimized a lot. But think to use Symfony form if you really need it. Otherwise, you can use plain form also. Make sure there are no multiple Symfony forms on a single page.
Start using stopwatch component
Use stopwatch component so you can measure time which code takes how much time to run. you can store stopwatch data in profiler component and then see information in profiler. It will be amazingly useful for speed up your web pages.
Use kernel.terminate event
Symfony kernel.terminate event is run after response sent to the user. So if you want to send mail then do in kernel.terminate. Think you are loading a page and mail is sending and then user see a response, so here the user has to wait for few seconds. But if you send a mail in the kernel.terminate then the user will see the fast response. So anything that can be done in the background you can run in kernel.terminate.
Use cache
Use varnish cache, http cache.
Symfony has great documentation for http cache. http://symfony.com/doc/current/http_cache.html By caching you will get faster performance.
Try to avoid subrequest
Avoid subrequest, means calling another controller action from one action or render Symfony controller action in twig. It will decrease performance. Use twig include statement. If view cannot do some work that you want to do then use twig extension.
Doctrine optimizations
Have limited connections open. See Symfony profiler. You can see how many queries are run in the page. You can also see query loading time. You can group similar statements in profiler and then do some optimizations in your query.
Comments
Post a Comment