Skip to main content

Symfony


Symfony can handle 660 requests/second and work great but you need to do some optimizations for that. Few Symfony sites are handling 1 billion requests per week without any issues.  Its all about how you follow framework standards and optimize the site.

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

Popular posts from this blog

As a symfony developer what you should take care when symfony standard edition is legacy:

Now  symfony standard edition is legacy . So no need to worry much just go threw article and understand whats new in symfony 4 if standard edition is legacy now. This is the main difference in Symfony 4 from symfony 2 and symfony 3 . Older symfony versions provide by default doctrine, twig, form, validation, profiler, annotations and many other components. But some time user do not want to use it. Suppose what if user do not want to doctrine or twig? Still he has doctrine and twig in his dependency. That makes symfony heavy framework. When starting a new project developers do not like to assemble things manually. So symfony 2 and 3 provides standard edition for developers to start a big project. But was hard to scale down project and decrease dependency if user do not require some packages. Symfony 2 and 3  are big success and in years developers are now aware with composer and dependency injection. So adding/removing a new package is not a big deal. So symfony chose...

Learn Angular 4 from scratch

Angular 4 is the latest version of AngularJs released in March 2017. The basic steps to accomplish our first Angular 4 hello world example. Here, we’ll simply create a component that passes the title from component to the view. 1. Install Angular CLI The Angular CLI is a command line interface that helps to scaffold and build angular apps in Node.js style. Also, it set up the angular 4 environments and will be helpful for us to work with angular apps like creating, running, etc. Now, install Angular-CLI. <code>npm install -g angular-cli</code> Once installation is done, just make sure that it’s installed by checking it’s version. <code>ng -v</code> 2. Install an Angular 4 Hello World App Here, we will create an app named hello-world ng new hello-world Now, go to the directory of a newly created project. cd hello-world Before running your app, let’s dive a bit deeper in coding behind the picture. 2.1 Fi...

3 Node.js Alternatives To WordPress

3 Node.js Alternatives To WordPress As compare to WordPress there is alternative option like Node.js. There are many various latest challengers that have large communities, support themes, plugins and are easy to install on your own server. Here are 3 you might want to checkout. KeystoneJS KeystoneJS is a content management system and framework to build server applications that interact with a database. It is based on the Express framework for Node.js and uses MongoDB for data storage. It represents a CMS alternative for web developers who want to build a data-driven website but don’t want to get into the PHP platform or large systems like WordPress. EnduroJS Enduro.js offers a fast and easy way to build your project, beautiful and simple admin UI and integrated tools to build everything on the server. It works without a database, instead relying on a system of flat files that can be opened directly in a text editor. It is easy to install and can be deployed via Git. ...